android.widget.TextView.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中android.widget.TextView.getParent()方法的一些代码示例,展示了TextView.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getParent()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getParent

TextView.getParent介绍

暂无

代码示例

代码示例来源:origin: chrisjenx/Calligraphy

/**
 * An even dirtier way to see if the TextView is part of the ActionBar
 *
 * @param view TextView to check is Title
 * @return true if it is.
 */
@SuppressLint("NewApi")
protected static boolean isActionBarSubTitle(TextView view) {
  if (matchesResourceIdName(view, ACTION_BAR_SUBTITLE)) return true;
  if (parentIsToolbarV7(view)) {
    final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();
    return TextUtils.equals(parent.getSubtitle(), view.getText());
  }
  return false;
}

代码示例来源:origin: chrisjenx/Calligraphy

/**
 * An even dirtier way to see if the TextView is part of the ActionBar
 *
 * @param view TextView to check is Title
 * @return true if it is.
 */
@SuppressLint("NewApi")
protected static boolean isActionBarTitle(TextView view) {
  if (matchesResourceIdName(view, ACTION_BAR_TITLE)) return true;
  if (parentIsToolbarV7(view)) {
    final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();
    return TextUtils.equals(parent.getTitle(), view.getText());
  }
  return false;
}

代码示例来源:origin: square/spoon

private void renderAmount() {
 double amountDouble = parsedAmount();
 String rendered = Moneys.formatDollars(amountDouble);
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  TransitionManager.beginDelayedTransition((ViewGroup) amountView.getParent());
 }
 amountView.setText(rendered);
 sendView.setEnabled(amountDouble > 1d);
}

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(root, savedInstanceState);
  final Toolbar toolbar = root.findViewById(R.id.toolbar);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      getActivity().finish();
    }
  });
  mRefreshLayout = root.findViewById(refreshLayout);
  mRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()).setSpinnerStyle(SpinnerStyle.FixedBehind).setPrimaryColorId(R.color.colorPrimary).setAccentColorId(android.R.color.white));
  mRefreshLayout.setOnRefreshListener(this);
  mRecyclerView = root.findViewById(recyclerView);
  mRecyclerView.setItemAnimator(new DefaultItemAnimator());
  mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
  mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
  mEmptyLayout = root.findViewById(R.id.empty);
  ImageView image = root.findViewById(R.id.empty_image);
  image.setImageResource(R.drawable.ic_empty);
  TextView empty = root.findViewById(R.id.empty_text);
  empty.setText("暂无数据点击刷新");
  ((View)empty.getParent()).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      doRefresh(0);
    }
  });
}

代码示例来源:origin: stackoverflow.com

ViewGroup parent = (ViewGroup)dialogTitleView.getParent();

代码示例来源:origin: Ramotion/garland-view-android

mMiddleCollapsible.add((View)mName.getParent());

代码示例来源:origin: guolindev/giffun

if (!mFileBrowserView.shouldShowItemSizes()) {
  ((View) holder.fileFolderSizeText.getParent()).setVisibility(View.GONE);
  RelativeLayout.LayoutParams titleParams = (RelativeLayout.LayoutParams)
      holder.fileFolderNameText.getLayoutParams();

代码示例来源:origin: objectbox/objectbox-performance

public PerfTestRunner(Activity activity, Callback callback, TextView textViewResults, int runs, int numberEntities) {
  this.activity = activity;
  this.callback = callback;
  this.textViewResults = textViewResults;
  if (textViewResults.getParent() instanceof ScrollView) {
    scrollViewResults = (ScrollView) textViewResults.getParent();
  }
  this.runs = runs;
  this.numberEntities = numberEntities;
}

代码示例来源:origin: stackoverflow.com

@Override
public void onClick(View v) {
  switch(v.getId()) {
    case R.id.ContactName:
      TextView tv = (TextView) v;
      LinearLayout ll = (LinearLayout) tv.getParent();
      QuickContactBadge qb = (QuickContactBadge) ll.findViewById(R.id.ContactBadge);
      qb.performClick();

      break;
  }
}

代码示例来源:origin: Janseon/CardMenuView

protected final View addLayoutContentView(int layoutResID, int index, LinearLayout.LayoutParams params) {
  View view = View.inflate(this, layoutResID, null);
  LinearLayout layout = (LinearLayout) title_view.getParent();
  layout.addView(view, index, params);
  return view;
}

代码示例来源:origin: stackoverflow.com

LinearLayout ll = (LinearLayout) findViewById(R.id.your_ll_id);
TextView tv = (LinearLayout) findViewById(R.id.your_tv_id);
ViewGroup parent = (ViewGroup) tv.getParent();
parent.removeView(tv);
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
//...
ll.addView(tv);

代码示例来源:origin: jasonliyihang/speed_tools

public void cancelToast() {
  if (mTextView != null && mTextView.getParent() != null) {
    mWindowManager.removeView(mTextView);
  }
}

代码示例来源:origin: stackoverflow.com

public void scrollToWord(String string) {
  TextView textView = (TextView) findViewById(R.id.text1);
  String text = textView.getText().toString();

  // Find the first occurrence of the word 
  int position = text.indexOf(string);
  // Calculate how far in the word is: 30%, 40%, 73% 
  int percent = (int) (position / (double) text.length() * 100);
  // Calculate how far to scroll
  int y = textView.getHeight() * percent;

  // Finally scroll
  ((ScrollView) textView.getParent()).scrollTo(0, y);
}

代码示例来源:origin: baidu/speech-samples

private void print(String msg) {
    txtLog.append(msg + "\n");
    ScrollView sv = (ScrollView) txtLog.getParent();
    sv.smoothScrollTo(0, 1000000);
    Log.d(TAG, "----" + msg);
  }
}

代码示例来源:origin: baidu/speech-samples

private void print(String msg) {
    long t = System.currentTimeMillis() - time;
    if (t > 0 && t < 100000) {
      txtLog.append(t + "ms, " + msg + "\n");
    } else {
      txtLog.append("" + msg + "\n");
    }
    ScrollView sv = (ScrollView) txtLog.getParent();
    sv.smoothScrollTo(0, 1000000);
    Log.d(TAG, "----" + msg);
  }
}

代码示例来源:origin: baidu/speech-samples

private void print(String msg) {
    txtLog.append(msg + "\n");
    ScrollView sv = (ScrollView) txtLog.getParent();
    sv.smoothScrollTo(0, 1000000);
    Log.d(TAG, "----" + msg);
  }
}

代码示例来源:origin: DFRobot/BlunoBasicDemo

@Override
public void onSerialReceived(String theString) {							//Once connection data received, this function will be called
  // TODO Auto-generated method stub
  serialReceivedText.append(theString);                            //append the text into the EditText
  //The Serial data from the BLUNO may be sub-packaged, so using a buffer to hold the String is a good choice.
  ((ScrollView)serialReceivedText.getParent()).fullScroll(View.FOCUS_DOWN);
}

代码示例来源:origin: stackoverflow.com

TextView tv = (TextView) progressDialog.findViewById(android.R.id.message);
tv.setTextColor(Portlet.MessageFontColor);

View v = (View) tv.getParent();
((ScrollView) v).setBackgroundColor(Portlet.messageBackColor);

v = (View) v.getParent();
v.setBackgroundColor(Portlet.messageBackColor);

LinearLayout ll = (LinearLayout) v.getParent();
ll.setBackgroundColor(Portlet.messageBackColor);

代码示例来源:origin: w446108264/StickHeaderLayout

@Override
  public void onHeaderTranslationY(float translationY) {
    float top = ((View)tv_title.getParent()).getBottom() - tv_title.getTop();
    tv_title.setTranslationY(Math.max(0,tv_headertitle.getTop() + top + translationY));
  }
});

代码示例来源:origin: blurpy/kouchat-android

/**
 * Clicks a menu item in the action bar. Expects the menu to be open.
 *
 * @param solo The solo tester.
 * @param title Title of the menu item to click.
 */
public static void clickMenuItem(final Solo solo, final String title) {
  final TextView topic = RobotiumTestUtils.getTextViewWithExactText(solo, title);
  solo.clickOnView((View) topic.getParent());
}

相关文章

TextView类方法