-1
我有一個滾動視圖,裏面是線性佈局,並且在線性佈局裏面有一些按鈕。我爲線性佈局定義了一些填充,但在滾動時,按鈕會忽略它並與滾動視圖重疊。該怎麼辦? 這裏是XML:Android,保持按鈕忽略父補間?
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="0dp"
android:layout_height="140dp"
android:layout_weight="1"
android:background="@drawable/item"
android:fadeScrollbars="false"
android:fadingEdge="none">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/item"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/Button03"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ff0000"
android:text="Button" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1e90ff" />
<Button
android:id="@+id/Button02"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ff0000"
android:text="Button" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1e90ff" />
<Button
android:id="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ff0000"
android:text="Button" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#1e90ff" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ff0000"
android:text="Button" />
</LinearLayout>
</ScrollView>
非常有用。使用滾動視圖中的所有內容滾動的這一觀點,我設法將滾動視圖設置爲線性佈局,並將填充設置爲滾動視圖本身而不是其子視圖。然後我做了線性佈局的角落圓角,現在一切都聽起來不錯。感謝Abhinav Puri。 –