Android 我能看见吗;按「;UI设计器中的状态?
我从xml中创建自定义可绘制文件,并尝试使用它创建选择器 按钮Android 我能看见吗;按「;UI设计器中的状态?,android,xml,Android,Xml,我从xml中创建自定义可绘制文件,并尝试使用它创建选择器 按钮 state_pressed=false: state_pressed=true 我将样式设置为我的按钮: <Button android:id="@+id/news_button" style="@style/green_button" ... /> 但现在我是斯塔克。我想将pressed属性设置为“true”,但在UI设计器中找不到该值。在UI设计器中可以看到按下的效果吗
state_pressed=false:
state_pressed=true
我将样式设置为我的按钮:
<Button
android:id="@+id/news_button"
style="@style/green_button"
...
/>
但现在我是斯塔克。我想将pressed属性设置为“true”,但在UI设计器中找不到该值。在UI设计器中可以看到按下的效果吗
我知道这是可能的方法。但这意味着我需要启动应用程序才能看到效果。如果你只是想看看它在按下时的样子,你可以交换按下状态的可绘制文件,即
android:drawable=“@drawable/green\u button\u with_solid”android:state\u pressed=“false”
,并在完成后将其还原。但这不是一个有效的解决方案:p@AbhishekV该死这是单一的解决方案吗?我不确定。可能还有其他解决办法。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:radius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
<size
android:width="48dp"
android:height="36dp" />
<solid android:color="#2ecc71" />
<stroke
android:width="2dp"
android:color="#2ecc71" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:radius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
<size
android:width="48dp"
android:height="36dp" />
<stroke
android:width="2dp"
android:color="#2ecc71" />
</shape>
<Button
android:id="@+id/news_button"
style="@style/green_button"
...
/>