我想将一个简单的渐变背景应用到我的主LinearLayout。我的问题是背景拒绝留在背景中,而是决定覆盖我的视图(在这种情况下,TextViews和Buttons)。我做错了什么/我错过了什么?谢谢你的帮助!Android - LinearLayout背景“over”视图
主要布局:
<?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:id="@+id/mainLinearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_gradient"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select the PC to communicate with..." />
<TextView
android:id="@+id/textViewStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Status" />
<RadioGroup
android:id="@+id/radioGroupDevices"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/btnBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="<<" />
<Button
android:id="@+id/btnVolDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<Button
android:id="@+id/btnPlayPause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="|>" />
<Button
android:id="@+id/btnVolUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+" />
<Button
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=">>" />
</LinearLayout>
</LinearLayout>
绘制/ bg_gradient.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="270" android:endColor="#181818" android:startColor="#616161"/>
<stroke android:width="1dp" android:color="#343434" />
</shape>
结果(截图来自Eclipse中的XML编辑器,但看起来实际手机上的相同) http://s14.directupload.net/images/130415/q8q6hcmn.png
正如你所看到的,文本行和按钮似乎至少是pa由背景覆盖。我也尝试使用普通的黑色背景,但效果相同。所有视图在黑色阴霾之后都显得“雾”。
我的API级别15个发展中国家,确实如此。对不起,离开了。您的建议确实将我的文字背景设置为粉红色。我想我可以把文字放在画布上,背景之上。但是,似乎每个文本都有一个背景,必须详细说明。所以我会尽量使视图的背景和布局背景尽可能匹配,以便无缝集成文本。我希望那是正确的路。感谢您的帮助! –
但是,似乎每个文本都带有背景......你能告诉我怎么在这里分享一些图像......如果你觉得这个有用的upvote或接受这个答案 –
在你的帮助下,我可以设置背景的文字变成黑色,按钮变成白色。 http://s14.directupload.net/images/130416/4c63r3bc.png 所以现在意见不再受到污染,但它仍然不是我所期待的效果。我只想(特别是文本)没有可见的背景,只是在阴影布局背景上出现白色。 我想upvote你的答案,但因为我是新来的我不能(更高的声誉要求)。我确实接受了你的回答。再次感谢! –