2015-10-19 2 views
0

Я проектирую экран для мобильных устройств (Android), я хотел отображать несколько текстовых полей и кнопок на экране.Как создать прокручиваемый макет

Кто-нибудь, пожалуйста, назовите меня, как я могу сделать свой экранный прокруткой, чтобы все текстовые поля и кнопки можно было создавать и просматривать на одной странице.

Я пробовал искать разные публикации, также пытался найти любую собственность, но не смог добиться успеха.

С уважением, Gul

ответ

0

Используйте ScrollView. Когда содержимое ScrollView не может соответствовать выделенной высоте, оно станет прокручиваемым.

Замечание что ScrollView может содержать только один прямой дочерний элемент, поэтому, если вам нужно несколько прокручиваемых объектов, вам необходимо обернуть это содержимое в макет.

Ниже приведен пример

<ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

     <TextView 
       android:id="@+id/tv_long" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:text="@string/really_long_string" > 
     </TextView> 

     <Button 
       android:id="@+id/btn_act" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="View" > 
     </Button> 
    </LinearLayout> 
</ScrollView> 

enter image description here

0

Использование Scrollview в качестве основного родительского макета. Если вы не даете прокрутку, вы не можете прокручивать страницу.

<?xml version="1.0" encoding="utf-8"?> 
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

    <LinearLayout 

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

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 1" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 2" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 3" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 4" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 5" /> 

     <ProgressBar 
      android:id="@+id/progressBar1" 
      style="?android:attr/progressBarStyleHorizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="RadioButton 1" /> 

     <RadioButton 
      android:id="@+id/radioButton1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="RadioButton 2" /> 

     <ToggleButton 
      android:id="@+id/toggleButton1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="ToggleButton" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 6" /> 

     <SeekBar 
      android:id="@+id/seekBar1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 7" /> 

     <Button 
      android:id="@+id/button4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 8" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="CheckBox" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 9" /> 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 10" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 11" /> 
    </LinearLayout> 

</ScrollView> 
Смежные вопросы