0
我有一個LinearLayout中的ScrollView以及頂部的標題LinearLayout。我給主LinearLayout一個背景。如果我保持ScrollView的背景,一切都會顯示正常。但是如果我添加了很多內容,那麼ScrollView背景就會延伸。所以我想讓ScrollView保持透明。Android ScrollView內容消失在去除背景屬性
但是,如果我刪除背景屬性,或者如果我嘗試android:background =「@ android:color/transparent」,ScrollView內的內容將消失。我可以看到的是來自外部LinearLayouts的標題和背景。
這是我多麼希望我的觀點:
<Linear Layout with background image>
<Header Linear Layout>
</Header Linear Layout>
<ScrollView with no background>
<Layouts in Scroll View>
</ScrollView>
下面是代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:orientation="vertical" >
<include layout="@layout/topbar" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
style="@style/Labels"
android:text="@string/posts_add_postcontent" />
<EditText
android:id="@+id/postsAddContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/posts_add_postcontent_h"
android:inputType="textMultiLine"
android:maxLength="3000"
android:minLines="3" />
</LinearLayout>
</ScrollView>
</LinearLayout>
注:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/topbar"
android:layout_width="fill_parent"
android:layout_height="30dip"
android:background="@layout/bgtop_repeat"
android:orientation="horizontal"
android:paddingTop="2dip" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:src="@drawable/cornerlogo" />
<Button
android:id="@+id/menubuton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/menubutton" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@layout/headshadow_repeat"
android:orientation="horizontal" />
</LinearLayout>
感謝:頭的LinearLayout通過另一個文件包含提前:)
完美!有效!不能相信這是一個小問題。謝謝 :) –