Hie*_*yen 1 android background transparent textview
我在布局中有一个 textview,我将单击侦听器设置为布局,并且在按下布局时更改了布局的颜色。但是我想将 textview 的背景设置为透明,但它不能。它采用窗口的背景(窗口的背景是灰色的,我的布局的背景是白色的)而不是布局的背景。
<LinearLayout android:layout_width="match_parent"
android:layout_height="50dp"
style="@style/TestLayout">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Test"
android:background="@android:color/transparent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在 styles.xml
<style name="TestLayout" parent="AppTheme.NoActionBar">
<item name="android:background">@drawable/selector_test_small_layout</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在 selector_test_small_layout
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true" android:state_enabled="true"
android:drawable="@drawable/s_pressed_layout" />
<item android:state_hovered="true" android:state_enabled="true"
android:drawable="@drawable/s_pressed_layout"/>
<item android:state_enabled="true" android:drawable="@drawable/s_color_primary"/>
<item android:state_enabled="false" android:drawable="@drawable/s_color_primary"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
更新:抱歉我的 xml 不够完整。明天我会正确更新它 Y_Y。现在我没有源代码,只有图片
更新:我在styles.xml 中包含了更多内容
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowContentOverlay">@null</item>
<item name="colorPrimary">@color/colorPrimary</item>
**<item name="android:windowBackground">@color/setting_divider</item>**
</style>
Run Code Online (Sandbox Code Playgroud)
在 AndroidManifest.xml 中
<application
android:name=".TestApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
**android:theme="@style/AppTheme**">
....
</application>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2106 次 |
| 最近记录: |