android 實現(xiàn)ScrollView自動滾動的實例代碼
有時候需要動態(tài)添加數(shù)據(jù),屏幕顯示滿了,數(shù)據(jù)需要滾動展示。這里主要弄懂scrollTo(0, off)方法的含義喊用法。
含義不說了,大概意思就這樣。
下面來看他的用法:
private void searchResultShow() {
TextView textView = new TextView(AFSearchActivity.this);
textView.setText("Text View ");
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
textView.setPadding(30, 15, 0, 15);
textView.setTextSize(30);
textView.setTextColor(Color.WHITE);
//增加一個TextView到線性布局中
layout.addView(textView, p);
ImageView imageView = new ImageView(AFSearchActivity.this);
imageView.setImageResource(R.drawable.im_dottend_line);
//增加一個ImageView到線性布局中
layout.addView(imageView, p);
if(sName == null || sName.equals("")){
textView.setText("-");
}else{
textView.setText(sName);
sName = "";
mHandler.post(mScrollToBottom);
}
}
private Runnable mScrollToBottom = new Runnable()
{
@Override
public void run()
{
int off = layout.getMeasuredHeight() - nameScroll.getHeight();
if (off > 0)
{
nameScroll.scrollTo(0, off);
}
}
};
- android開發(fā)之橫向滾動/豎向滾動的ListView(固定列頭)
- android實現(xiàn)上下滾動的TextView
- android TextView不用ScrollViewe也可以滾動的方法
- Android中實現(xiàn)多行、水平滾動的分頁的Gridview實例源碼
- Android GridView實現(xiàn)滾動到指定位置的方法
- android開發(fā)教程之文本框加滾動條scrollview
- Android SeekBar實現(xiàn)禁止滑動
- Android SeekBar實現(xiàn)滑動條效果
- Android自定義SeekBar滑動顯示數(shù)字
- Android SeekBar實現(xiàn)平滑滾動
相關文章
Android Jetpack導航組件Navigation創(chuàng)建使用詳解
這篇文章主要為大家介紹了Android Jetpack導航組件Navigation創(chuàng)建及使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11Android基于google Zxing實現(xiàn)各類二維碼掃描效果
這篇文章主要介紹了Android基于google Zxing實現(xiàn)各類二維碼掃描效果的相關資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-02-02Flutter懸浮按鈕FloatingActionButton使用詳解
本文主要介紹了Flutter懸浮按鈕FloatingActionButton使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-07-07Android Flutter實現(xiàn)圖片滑動切換效果
Flutter 為了簡化開發(fā),提供了不少轉換動畫組件,這類組件通常命名為 xxTransition。本篇要介紹的就是 SlideTransition,并用它實現(xiàn)圖片滑動切換效果,感興趣的可以了解一下2022-04-04