Android-прокрутка перекрывается с ключевым элементом макета - PullRequest
4 голосов
/ 14 декабря 2011

Я столкнулся с проблемой, когда моя полоса прокрутки перекрывается элементом из моего макета. Я хотел бы, чтобы полоса прокрутки появилась после поля редактирования: enter image description here. При добавлении полосы прокрутки к различным частям XML-файла я получил сообщения об ошибках, которые, как я понимаю, означают, что представление прокрутки должно быть корневым элементом. В результате мой код выглядит следующим образом (когда я чувствую, что представление прокрутки должно появляться после первого линейного макета и / или поля редактирования):

<?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/db1_root"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout style="@style/TitleBar">
        <ImageView style="@style/TitleBarLogo"
            android:contentDescription="@string/description_logo"
            android:src="@drawable/logo" />

        <ImageView style="@style/TitleBarSeparator" />
        <TextView style="@style/TitleBarText" />
        <ImageButton style="@style/TitleBarAction"
            android:contentDescription="@string/description_about"
            android:src="@drawable/about"
            android:onClick="onClickAbout" />
    </LinearLayout>

<LinearLayout
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <EditText 
        android:layout_width="match_parent" 
        android:id="@+id/status" 
        android:layout_height="wrap_content">
        <requestFocus></requestFocus>
    </EditText>
 <Button android:layout_width="wrap_content" android:text="Ok" android:textColor="@color/title_text" android:layout_gravity="center" android:background="@drawable/custom_button" android:layout_height="wrap_content"></Button>
    <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
        <TextView android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content" android:text="" android:id="@+id/updates" android:textSize="14dp" android:layout_height="wrap_content"></TextView>
    </LinearLayout>
    <TextView android:text="" android:id="@+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
</LinearLayout>
</LinearLayout>
 </ScrollView>

Ответы [ 3 ]

5 голосов
/ 14 декабря 2011

Это может работать для вас: android:scrollbarStyle="outsideOverlay", установите это внутри <ScrollView>

0 голосов
/ 14 декабря 2011

Я понял это после разговора с коммунгу (+1).Я неправильно понял ошибку андроида, которую я получил о представлениях прокрутки и корневых элементах.Насколько я понимаю, представление прокрутки может иметь только одного ребенка.Сначала я думал, что представление прокрутки должно быть окружено корневым элементом (упс).Вот исправление:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/db1_root"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout style="@style/TitleBar">
        <ImageView style="@style/TitleBarLogo"
            android:contentDescription="@string/description_logo"
            android:src="@drawable/logo" />

        <ImageView style="@style/TitleBarSeparator" />
        <TextView style="@style/TitleBarText" />
        <ImageButton style="@style/TitleBarAction"
            android:contentDescription="@string/description_about"
            android:src="@drawable/about"
            android:onClick="onClickAbout" />
    </LinearLayout>

<LinearLayout
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <EditText 
        android:layout_width="match_parent" 
        android:id="@+id/status" 
        android:layout_height="wrap_content">
        <requestFocus></requestFocus>
    </EditText>
 <Button 
    android:layout_width="wrap_content" 
    android:text="Go" 
    android:textColor="@color/title_text" 
    android:layout_gravity="center" 
    android:id="@+id/communitysubmit" 
    android:background="@drawable/custom_button" 
    android:layout_height="wrap_content">
 </Button>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >
    <LinearLayout 
        android:layout_width="match_parent" 
        android:id="@+id/linearLayoutcommunity" 
        android:layout_height="wrap_content" 
        android:orientation="vertical">
     <TextView 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:layout_width="wrap_content" 
        android:text="" 
        android:id="@+id/updates" 
        android:textSize="14dp" 
        android:layout_height="wrap_content">
    </TextView>
    </LinearLayout>
    </ScrollView>
    <TextView 
        android:text="" 
        android:id="@+id/test" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">
    </TextView> 
</LinearLayout>
</LinearLayout>
0 голосов
/ 14 декабря 2011

Дайте свой LinearLayout или ScrollView немного padding.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...