導航:首頁 > 操作系統 > Androidscrollbar高度

Androidscrollbar高度

發布時間:2022-05-09 03:16:39

1. android如何讓ScrollView的滾動條定位到最後一行

單獨定義一個靜態方法,建立一個線程判斷滾動條的內層外層高度變化。
ScrollView
scrollresult=(ScrollView)findViewById(R.id.scrollView);
scroll2Bottom(scrollresult,
txthistroycontent);//txthistroycontent為滾動條關聯的文本框
public
static
void
scroll2Bottom(final
ScrollView
scroll,
final
View
inner)
{
Handler
handler
=
new
Handler();
handler.post(new
Runnable()
{
@Override
public
void
run()
{
//
TODO
Auto-generated
method
stub
if
(scroll
==
null
||
inner
==
null)
{
return;
}
//
內層高度超過外層
int
offset
=
inner.getMeasuredHeight()
-
scroll.getMeasuredHeight();
if
(offset
<
0)
{
System.out.println("定位...");
offset
=
0;
}
scroll.scrollTo(0,
offset);
}
});
}
}

2. 如何動態測量ListView的高度

item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="
android:layout_width="wrap_content"
android:layout_height="44dp"
android:paddingLeft="10dp"
android:background="@color/white"
android:descendantFocusability="blocksDescendants"
android:paddingBottom="1dp">

android:id="@+id/tv_contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/iv_contact_photo"
android:textColor="@color/black" />
android:id="@+id/iv_contact_photo"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="5dp" />

在使用此listView的布局中設置屬性
<ListView
android:id="@+id/lv_addEventContact"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarSize="0dp"
android:dividerHeight="0dp"
android:visibility="gone"
/>
定義一個函數將dp轉換為像素
public int Dp2Px(Context context, float dp) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);
}
定義函數動態控制listView的高度
public void (ListView listView) {
//獲取listview的適配器
ListAdapter listAdapter = listView.getAdapter();
//item的高度
int itemHeight = 46;
if (listAdapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
totalHeight += Dp2Px(getApplicationContext(),itemHeight)+listView.getDividerHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight;
listView.setLayoutParams(params);
}
在每次listView的adapter發生變化後,要調用(listView)更新界面

3. 如何讓ScrollView 的滾動條不顯示

正好也遇到這個問題,剛看到的分享下

android:background 設置背景色/背景圖片。可以通過以下兩種方法設置背景為透明:」@android:color/transparent」和」@null」。注意TextView默認是透明的,不用寫此屬性,但是Buttom/ImageButton/ImageView想透明的話就得寫這個屬性了。
android:clickable 是否響應點擊事件。
android:contentDescription 設置View的備注說明,作為一種輔助功能提供,為一些沒有文字描述的View提供說明,如ImageButton。這里在界面上不會有效果,自己在程序中控制,可臨時放一點字元串數據。
android:drawingCacheQuality 設置繪圖時半透明質量。有以下值可設置:auto(默認,由框架決定)/high(高質量,使用較高的顏色深度,消耗更多的內存)/low(低質量,使用較低的顏色深度,但是用更少的內存)。
android:plicateParentState 如果設置此屬性,將直接從父容器中獲取繪圖狀態(游標,按下等)。 見下面代碼部分,注意根據目前測試情況僅僅是獲取繪圖狀態,而沒有獲取事件,也就是你點一下LinearLayout時Button有被點擊的效果,但是不執行點擊事件。
android:fadingEdge 設置拉滾動條時 ,邊框漸變的放向。none(邊框顏色不變),horizontal(水平方向顏色變淡),vertical(垂直方向顏色變淡)。參照fadingEdgeLength的效果圖
android:fadingEdgeLength 設置 邊框漸變的長度。
android:fitsSystemWindows 設置布局調整時是否考慮系統窗口(如狀態欄)
android:focusable 設置是否獲得焦點。若有requestFocus()被調用時,後者優先處理。注意在表單中想設置某一個如EditText獲取焦點,光設置這個是不行的,需要將這個EditText前面的focusable都設置為false才行。在Touch模式下獲取焦點需要設置focusableInTouchMode為true。
android:focusableInTouchMode 設置在Touch模式下View是否能取得焦點。
android:hapticFeedbackEnabled 設置長按時是否接受其他觸摸反饋事件。這里模擬器沒有試出效果,難道是多點觸摸?找不到資料可以找找performHapticFeedback或HapticFeedback這個關鍵字的資料看看。
android:id 給當前View設置一個在當前layout.xml中的唯一編號,可以通過調用View.findViewById() 或Activity.findViewById()根據這個編號查找到對應的View。不同的layout.xml之間定義相同的id不會沖突。格式如」@+id/btnName」
android:isScrollContainer 設置當前View為滾動容器。這里沒有測試出效果來,ListView/ GridView/ ScrollView根本就不用設置這個屬性,而EdidText設置android:scrollbars也能出滾動條。
android:keepScreenOn View在可見的情況下是否保持喚醒狀態。

常在LinearLayout使用該屬性,但是模擬器這里沒有效果。
android:longClickable 設置是否響應長按事件.
android:minHeight 設置視圖最小高度
android:minWidth 設置視圖最小寬度度
android:nextFocusDown 設置下方指定視圖獲得下一個焦點。焦點移動是基於一個在給定方向查找最近鄰居的演算法。如果指定視圖不存在,移動焦點時將報運行時錯誤。可以設置imeOptions= actionDone,這樣輸入完即跳到下一個焦點。
android:nextFocusLeft 設置左邊指定視圖獲得下一個焦點。
android:nextFocusRight 設置右邊指定視圖獲得下一個焦點。
android:nextFocusUp 設置上方指定視圖獲得下一個焦點。
android:onClick 點擊時從上下文中調用指定的方法。這里指定一個方法名稱,一般在Activity定義符合如下參數和返回值的函數並將方法名字元串指定為該值即可:

public void onClickButton(View view)
android:onClick=」 onClickButton」
android:padding 設置上下左右的邊距,以像素為單位填充空白。
android:paddingBottom 設置底部的邊距,以像素為單位填充空白。
android:paddingLeft 設置左邊的邊距,以像素為單位填充空白。
android:paddingRight 設置右邊的邊距,以像素為單位填充空白。.
android:paddingTop 設置上方的邊距,以像素為單位填充空白。
android:saveEnabled 設置是否在窗口凍結時(如旋轉屏幕)保存View的數據,默認為true,但是前提是你需要設置id才能自動保存,參見這里。

android:scrollX 以像素為單位設置水平方向滾動的的偏移值,在GridView中可看的這個效果。
android:scrollY 以像素為單位設置垂直方向滾動的的偏移值
android: 設置是否始終顯示垂直滾動條。這里用ScrollView、ListView測試均沒有效果。
android: 設置是否始終顯示垂直滾動條。這里用ScrollView、ListView測試均沒有效果。
android: 設置N毫秒後開始淡化,以毫秒為單位。
android:scrollbarFadeDuration 設置滾動條淡出效果(從有到慢慢的變淡直至消失)時間,以毫秒為單位。Android2.2中滾動條滾動完之後會消失,再滾動又會出來,在1.5、1.6版本裡面會一直顯示著。
android:scrollbarSize 設置滾動條的寬度。
android:scrollbarStyle 設置滾動條的風格和位置。設置值:insideOverlay、insideInset、outsideOverlay、outsideInset。這里沒有試出太多效果,以下依次是outsideOverlay與outsideInset效果截圖比較:
android:scrollbarThumbHorizontal 設置水平滾動條的drawable(如顏色)。
android:scrollbarThumbVertical 設置垂直滾動條的drawable(如顏色).
android:scrollbarTrackHorizontal 設置水平滾動條背景(軌跡)的色drawable(如顏色)
android:scrollbarTrackVertical 設置垂直滾動條背景(軌跡)的drawable注意直接設置顏色值如」android:color/white」將得出很難看的效果,甚至都不理解這個屬性了,這里可以參見ApiDemos里res/drawable/ scrollbar_vertical_thumb.xml和scrollbar_vertical_track.xml,設置代碼為:android:scrollbarTrackVertical ="@drawable/scrollbar_vertical_track"
android:scrollbars 設置滾動條顯示。none(隱藏),horizontal(水平),vertical(垂直)。見下列代碼演示使用該屬性讓EditText內有滾動條。但是其他容器如LinearLayout設置了但是沒有效果。
android:soundEffectsEnabled 設置點擊或觸摸時是否有聲音效果
android:tag 設置一個文本標簽。可以通過View.getTag()或 for with View.findViewWithTag()檢索含有該標簽字元串的View。但一般最好通過ID來查詢View,因為它的速度更快,並且允許編譯時類型檢查。
android:visibility 設置是否顯示View。設置值:visible(默認值

4. Android 滾動條 ProgressBar 怎麼停止

如果把內容包含在ScrollView中,當內容超出高度時會自動出現滾動條。
另外,使用控制項HorizontalScrollView 來包住內容時,
如果內容假設是一個LinearLayout, 那麼當LinearLayout的寬度超過屏幕時, 將會自動產生滾動條,當拖動滑鼠時,效果跟scrollView一樣,不過是橫向而己

5. android scrollview的水平滾動條問題,哪位高手給指教下啊,謝謝了!!

如果你把內容包含在ScrollView中,當內容超出高度時會自動出現滾動條。

另外,使用控制項HorizontalScrollView 來包住你的內容時,
如果你的內容假設是一個LinearLayout, 那麼當LinearLayout的寬度超過屏幕時, 將會自動產生滾動條,當你拖動滑鼠時,效果跟scrollView一樣,不過是橫向而己

例:
縱向滾動
<ScrollView>
<LinearLayout ........>
<TextView ...../>
<TextView ...../>
<TextView ...../>
<TextView ...../>
</LineraLayout>
</ScrollView>

模向滾動
<HorizontalScrollView >
<LinearLayout ........>
<TextView ...../>
<TextView ...../>
<TextView ...../>
<TextView ...../>
</LineraLayout>
</HorizontalScrollView >

有時候甚至可以做到橫向縱向都支持,只需要你合理設計就可以, 注意ScrollView中只能加一個控制,不能超過兩個

6. 滾動條按鈕的高度怎麼設置scrollbar-track-piece

vb適當設置滾動條的大小和位置通過以下參數實現: 說明;滾動條控制項(ScrollBar)分為水平滾動條(HScrollbar)和垂直滾動條(VscrollBar)二種,通常附在窗體上協助觀察數據或確定位置,也可用作數據輸入工具,用來提供某一范圍內的數值供用戶...

7. android 怎樣讓滾動條長度隨著文本內容變化而變化

明白樓主想幹嘛了.
一個TextView,顯示從xml里讀出來的數據,因為可能數據量比較大,TextView顯示不下.

其實TextView沒有你說的功能,但你想要做到很簡單,在最外層套一個ScrollView就好了,顯示不下就會有滾動條了.

8. android TextView滾動條設置android:ellipsize="marquee" android:scrollbars="horizontal" android:marqu

1.你滾動條包含的列表項要超過頁面顯示範圍
2.mxl代碼中多所有的列表項都要包含在scroll中。(也就是scroll要把列表項括起來)
隨便給你段代碼 scroll裡面的內容不用仔細看,就是一些列表組件什麼的。注意sroll的格式就好了

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#ff888888">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff888888">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#ff888888">
<TextView android:layout_width="wrap_content" android:id="@+id/Text" android:layout_height="wrap_content" android:text="@string/title" android:layout_gravity="center" android:textColor="#ffff00ff" android:textSize="30sp" android:layout_marginBottom="10px" android:layout_marginTop="30px"></TextView>

<Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:text="@string/backlight" android:id="@+id/backlight"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/screen" android:text="@string/screen"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/speaker" android:text="@string/speaker"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/headset" android:text="@string/headset"></Button>
<Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:text="@string/vibrator" android:id="@+id/vibrator"></Button>
<Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/battery" android:text="@string/battery"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:text="@string/dial" android:id="@+id/dial"></Button><Button android:gravity="left" android:layout_width="fill_parent" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/fingerpaint" android:text="@string/fingerpaint"></Button>
<Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:text="@string/touchpanel" android:id="@+id/touchpanel"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:text="@string/gsensor" android:id="@+id/gsensor"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/camera" android:text="@string/camera"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/wifi" android:text="@string/wifi"></Button>

<Button android:id="@+id/picture" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:layout_width="fill_parent" android:text="@+string/picture"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/bluetooth" android:text="@string/bluetooth"></Button><Button android:layout_width="fill_parent" android:gravity="left" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:id="@+id/keypress" android:text="@string/keypress"></Button><Button android:id="@+id/locateme" android:text="GPS" android:layout_width="fill_parent" android:textSize="25sp" android:layout_height="50px" android:layout_marginBottom="2px" android:gravity="left"></Button>
</LinearLayout>
</ScrollView>

</LinearLayout>

9. 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); }

10. android中設置的垂直滾動條,當圖片在放大之後,圖片上端有一部分顯示不了,下面可以全部顯示

你把scrollView的 android:layout_centerVertical="true" 和下面水平 ="true" 換成

android:gravity="centerVertical|centerHorizontal" layout_center... 說的是他自己本身

閱讀全文

與Androidscrollbar高度相關的資料

熱點內容
web前端後端程序員 瀏覽:24
萬能zip的壓縮包怎麼解壓 瀏覽:40
國內動漫用什麼app看 瀏覽:353
樹莓派高級編程 瀏覽:928
30歲學編程晚嗎 瀏覽:68
解壓專家怎麼打開 瀏覽:86
php開源留言板 瀏覽:49
新鄉市區疫情怎麼查詢app 瀏覽:158
我的世界伺服器怎麼弄圖 瀏覽:999
vc6的編譯框 瀏覽:198
程序員寫照 瀏覽:539
怎麼退出github伺服器版本 瀏覽:797
雲伺服器sip 瀏覽:910
對稱平衡型壓縮機 瀏覽:953
rust連接什麼伺服器 瀏覽:382
php刪除數組的空元素 瀏覽:74
有什麼古今翻譯的app 瀏覽:54
華為平板里的app熱門推薦怎麼關閉 瀏覽:731
kindle可以看pdf嗎 瀏覽:620
小米文件夾變小 瀏覽:324