當前位置:首頁 » 安卓系統 » android滾動欄

android滾動欄

發布時間: 2023-08-11 21:48:59

『壹』 怎麼在android中出現滾動界面

使用ScrollView即可。

例如:

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:scrollbars="vertical"

android:fadingEdge="vertical"

>

android:orientation="vertical" android:layout_width="fill_parent"

android:layout_height="wrap_content" android:padding="10dip"

android:scrollbars="vertical"

>

注意的是:ScrollView也是一個layout布局,可以讓它的內容數據顯示不下的時候出現滾動條。但是不能在ScrollView中放置多個組件,Scrollview只能包裹一個子元素。可以在Scrollview中放置一個LinearLayout或其他layout來放置更多組件(Layout可以嵌套的)。

『貳』 android 編程怎麼添加滾動條

給TextView加上滾動條非常簡單,只需要把TextView標簽放在ScrollView標簽中
[html] view plain print?
<ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/txtViewHtml" />
</ScrollView>

『叄』 android中怎樣隱藏滾動條

android中隱藏滾動條的方法:
1. 在<ListView>標簽中設置屬性,android:fastScrollEnabled="false"
2. 以下屬性scrollbars可以設置為none也可以不設置為none。效果會有點不同。根據具體情況決定是否設置為none,android:scrollbars="none"
3. 屬性fastScrollEnabled說明:
Enables the fast scroll thumb that can be dragged to quickly
scroll through the list. [boolean]
譯:允許fast scroll thumb可以拖動來快速滾動列表。
4. 屬性scrollbars說明:
Defines which scrollbars should be displayed on scrolling or not.
譯:定義在scrolling時哪個滾動條應該顯示出來,或者不顯示。

『肆』 Android scrollview滾動條顯示不出來怎麼辦

正好也遇到這個問題,剛看到的分享下 android:background 設置背景色/背景圖片。可以通過以下兩種方法設置背景為透明:」@android:color/transparent」和」@null」。注意TextView默認是透明的,不用寫此屬性,但是Buttom/ImageButton/ImageView想透

『伍』 android手動拖動滾動條高速滑動怎麼解決

android手動拖動滾動條快速滑動

只需在ListView中加入一個參數
android:fastScrollEnabled="true" android:focusable="true"
android的源代碼如下:
在contacts_list_content.xml中:
<com.android.contacts.FocusRequestingListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true"
/>
而FocusRequestingListView 的源代碼如下:
public class FocusRequestingListView extends ListView {
private boolean mFirstLayoutDone = false;
public FocusRequestingListView(Context context) {
super(context);
}
public FocusRequestingListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FocusRequestingListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (!mFirstLayoutDone) {
setFocusable(true);
requestFocus();
}
mFirstLayoutDone = true;
}
}
其實有用的就這么兩句話,
if (!mFirstLayoutDone) {
setFocusable(true);
requestFocus();
}
mFirstLayoutDone = true;
說的意思就是在什麼情況下設置focusable焦點。

很多開發者不知道ListView列表控制項的快速滾動滑塊是如何啟用的,這里Android開發網告訴大家,輔助滾動滑塊只需要一行代碼就可以搞定,如果你使用XML布局只需要在ListView節點中加入 android:fastScrollEnabled="true" 這個屬性即可,而對於Java代碼可以通過myListView.setFastScrollEnabled(true); 來控制啟用,參數false為隱藏。

還有一點就是當你的滾動內容較小,不到當前ListView的3個屏幕高度時則不會出現這個快速滾動滑塊,同時該方法仍然是AbsListView的基礎方法,可以在ListView或GridView等子類中使用快速滾動輔助。

『陸』 android類似群公告的滾動模塊應該怎麼實現

實現滾動欄里多條消息的自切換;
點擊後獲取具體內容。
簡單是實現代碼:
public class PublicNoticeView extends LinearLayout {

private static final String TAG = "LILITH";
private Context mContext;
private ViewFlipper viewFlipper;
private View scrollTitleView;
private Intent intent;

Handler mHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
switch (msg.what) {
case 1:

//bindNotices();
break;

case -1:
break;
}
}
};

/**
* 構造
* @param context
*/
public PublicNoticeView(Context context) {
super(context);
mContext = context;
init();
}

public PublicNoticeView(Context context,AttributeSet attrs) {
super(context, attrs);
mContext = context;
init();

}

/**
* 網路請求後返回公告內容進行適配
*/
protected void bindNotices() {
// TODO Auto-generated method stub
viewFlipper.removeAllViews();
int i = 0;
while(i<5){
String text = "公告:中獎了 5000w-------";
TextView textView = new TextView(mContext);
textView.setText(text);
textView.setOnClickListener(new NoticeTitleOnClickListener(mContext,i+text));
LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
viewFlipper.addView(textView,lp);
i++;
}
}

private void init(){
bindLinearLayout();
Message msg = new Message();
msg.what = 1;
mHandler.sendMessageDelayed(msg, 3000);

}

/**
* 初始化自定義的布局
*/
public void bindLinearLayout() {
scrollTitleView = LayoutInflater.from(mContext).inflate(
R.layout.main_public_notice_title, null);
LayoutParams layoutParams = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
addView(scrollTitleView, layoutParams);

viewFlipper = (ViewFlipper) scrollTitleView
.findViewById(R.id.flipper_scrollTitle);
viewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext, android.R.anim.slide_in_left));
viewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext, android.R.anim.slide_out_right));
viewFlipper.startFlipping();
View v = viewFlipper.getCurrentView();

}

/**
* 獲取公告資訊
*/
public void getPublicNotices(){
//網路請求獲取
}

/**
* 公告title監聽
* @author Nono
*
*/
class NoticeTitleOnClickListener implements OnClickListener{
private Context context;
private String titleid;

public NoticeTitleOnClickListener(Context context, String whichText){
this.context = context;
this.titleid = whichText;
}
public void onClick(View v) {
// TODO Auto-generated method stub
disPlayNoticeContent(context,titleid);
}

}

/**
* 顯示notice的具體內容
* @param context
* @param titleid
*/
public void disPlayNoticeContent(Context context, String titleid) {
// TODO Auto-generated method stub
Toast.makeText(context, titleid, Toast.LENGTH_SHORT).show();
intent = new Intent(context, InformationContentActivity.class);
intent.putExtra("tag", titleid);
((Activity)context).startActivity(intent);
}

}

『柒』 Android ViewPager + Fragment 實現導航欄(可以左右滑動)

先上圖

使用HorizontalScrollView可以讓超出屏幕的導航欄可以滑動,每個RadioButton代表一個導航標題,android:button="@null"去掉RadioButton的選中圓圈

選中的下劃線xml文件

將RadioButton導航欄的標題裝在一個list集合裡面,新增標題的時候可以直接在list里添加RadioButton的id,簡約了ViewPage滑動定位到相應的RadioButton和相應的Fragment,不用when每個id去判斷。

增加標題時也要add對應的Fragment

繼承FragmentStatePagerAdapter 。當ViewPager中的Fragment數量相對較多時繼承FragmentStatePagerAdapter,少時可以繼承FragmentPagerAdapter

『捌』 Android實現橫縱滾動標題不動框架

用自定義標題欄。
用自定義標題欄,只要把系統自帶的標題欄去掉就行。做法:requestWindowFeature(Window.FEATURE_NO_TITLE),自己再寫兩個布局塊(LinearLayout布局)充當頂部和底部的標題欄即可,中間使用ScrollView即可完成。
如果應用需要添加水平滾動條,則可藉助於另一個滾動視圖HorizontalScrollView來實現。

『玖』 android中怎樣設置滾動條

mThumbDrawable 這個文件沒有,根本為崩潰; 並不是方法不好用,是你沒有抄全; 在實際應用中,該代碼會出現異常,通過對幾個sdk源碼的對比,發現Google會對其中的屬性做一些微調: 如在5.x中,「mFastScroller」改為了「mFastScroll」,4.4中則把「mThumbDrawable」改為「thumbDrawable」並設為了final,在5.x中又恢復成了private. 所以在實際應用中還需加以判斷。下面是針對4.4修改後的代碼: 由於class FastScroller沒有public屬性,無法直接導包獲取到,所以從用到該類的AbsListView中獲取。 try { Field f = AbsListView.class.getDeclaredField("mFastScroller"); //獲取AbsListView中的屬性mFastScroller f.setAccessible(true);//設置屬性可修改 Object o = f.get(listview);//得到listview實例 // Field[] fields = f.getType().getDeclaredFields(); // for (Field field : fields) { // Log.v("TAG", field.getName()); // } //查看所有屬性名 f = f.getType().getDeclaredField("mThumbImage");//獲取屬性mThumbImage(由於 4.4中的thumbDrawable不可修改,所以直接取其imageview) f.setAccessible(true); ImageView img = (ImageView) f.get(o); //得到ImageView實例 img.setImageDrawable(getResources().getDrawable(R.drawable.icon)); f.set(o, img); //把編輯好的ImageView放進去 } catch (Exception e) { throw new RuntimeException(e); }

熱點內容
滑板鞋腳本視頻 發布:2025-02-02 09:48:54 瀏覽:433
群暉怎麼玩安卓模擬器 發布:2025-02-02 09:45:23 瀏覽:558
三星安卓12彩蛋怎麼玩 發布:2025-02-02 09:44:39 瀏覽:744
電腦顯示連接伺服器錯誤 發布:2025-02-02 09:24:10 瀏覽:537
瑞芯微開發板編譯 發布:2025-02-02 09:22:54 瀏覽:147
linux虛擬機用gcc編譯時顯示錯誤 發布:2025-02-02 09:14:01 瀏覽:240
java駝峰 發布:2025-02-02 09:13:26 瀏覽:652
魔獸腳本怎麼用 發布:2025-02-02 09:10:28 瀏覽:538
linuxadobe 發布:2025-02-02 09:09:43 瀏覽:212
sql2000資料庫連接 發布:2025-02-02 09:09:43 瀏覽:726