我正在面对一个奇怪的问题,因为当我向上/向下滚动时,孩子的背景会闪烁。重要的是我在scrollview中有一个edittext。另外,根据我的视觉设计,我需要将背景应用于其中一个子布局。为了更清楚地理解这个问题,我在下面嵌入了我的布局代码片段,希望能得到解决方案。
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#eeeeee" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="20dip"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/whitebg"
android:orientation="vertical" >
<EditText
android:layout_width="fill_parent"
android:layout_height="44dip"
android:layout_marginBottom="20dip"
android:layout_marginTop="800dip"
android:background="@drawable/orangebg" />
</LinearLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click to Next screen" />
</LinearLayout>
</ScrollView>
`
注意:最低android sdk为android:minSdkVersion="14"
答案 0 :(得分:0)
如果有效,请更改为此内容,为您的scrollview子项linearlayout提供透明背景:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#eeeeee" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="20dip"
android:background="@android:color/transparent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/whitebg"
android:orientation="vertical" >
<EditText
android:layout_width="fill_parent"
android:layout_height="44dip"
android:layout_marginBottom="20dip"
android:layout_marginTop="800dip"
android:background="@drawable/orangebg" />
</LinearLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click to Next screen" />
</LinearLayout>
</ScrollView>