[英]Android layout, dragging or sliding?
現在,我知道這聽起來完全是愚蠢的。 但是,當您擁有智能手機或平板電腦並在屏幕上拖動手指以將應用程序下移以訪問更多屏幕上無法訪問的元素時,這又叫什么呢?
我問的原因是因為我日食並於前一天開始學習android java。 太好了,很有趣。 但是,實際上我已經設法將一個不錯的小應用程序放在一起。 問題是,當我在某些仿真器中對其進行測試時; 屏幕對於應用程序來說太小了,我無法訪問最后的輸入和提交按鈕。 我不知道這個東西叫什么,或者我什至可以通過谷歌搜索來弄清楚如何使屏幕向下移動以訪問它們。
拜托,我是認真的。 任何幫助或指示將不勝感激。 謝謝!
看看ScrollView 。 它可以像網站一樣實現滾動行為,從而使布局比實際屏幕尺寸“更大”。
需要注意的一件事; ScrollView
只能包含一個直接子級。 因此,如果布局包含多個Views
(例如TextViews
和Buttons
,則必須將它們全部包裝在LinearLayout
或RelativeLayout
。
有很多孩子的布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout id="@+id/wrapper_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView />
<EditText />
<Button />
</LinearLayout>
</ScrollView
當您只有一個孩子時,不需要“包裝器”布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView id="@+id/lots_of_text_that_need_scrolling" />
</ScrollView>
您需要將布局放在ScrollView中。 然后,當您向上滑動手指以顯示屏幕底部時,屏幕將能夠滾動。
我相信您要尋找的字詞正在掃動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.