Android 不带立面的AppCompat按钮
我的应用程序中有几十个按钮,并且有一种继承自Widget.AppCompat.Button的风格。大多数按钮都有高程和状态更改动画。太棒了 不可怕的是,一些按钮没有任何额外的优点 下面是一个工作按钮的示例Android 不带立面的AppCompat按钮,android,android-button,android-appcompat,android-elevation,Android,Android Button,Android Appcompat,Android Elevation,我的应用程序中有几十个按钮,并且有一种继承自Widget.AppCompat.Button的风格。大多数按钮都有高程和状态更改动画。太棒了 不可怕的是,一些按钮没有任何额外的优点 下面是一个工作按钮的示例 <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="?attr/defaultPadding"
android:minHeight="?attr/minTouchSize"
android:textAppearance="?attr/textAppearanceListRowLabel" />
这里有一个按钮不起作用的片段
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:minHeight="?attr/minTouchSize" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="?attr/minTouchSize" />
</LinearLayout>
这些在单独的布局上。我尝试过的事情:
- 我已经将
添加到与按钮栏相同的布局文件中,button1
仍然有效button1
- 如果我从栏中的一个按钮上移除权重,它们将不起作用
- 我已经尝试过在每个按钮上明确显示我的按钮样式
- 如果我将按钮栏设置为垂直布局,并使按钮与父按钮匹配,那么它就会工作!但那不是我想要的
我正在使用appcompat 22.2.1我想问题出在你的活动主题上 值得一提的是,按钮的风格来自活动主题。 你能做的是:
<style name="ThemeMaterialButtonColor" parent="Base.Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/md_teal_500</item></style>
@颜色/md_teal_500
我想问题出在你的活动主题上 值得一提的是,按钮的风格来自活动主题。 你能做的是:
<style name="ThemeMaterialButtonColor" parent="Base.Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/md_teal_500</item></style>
@颜色/md_teal_500
您是否尝试在每个按钮上显式地添加样式?@Androider遗憾的是没有骰子:/我尝试删除minHeight属性,并将代码放入活动的主布局中,效果很好。这些参数可能有问题。您是否尝试在每个按钮上显式添加样式?@Androider遗憾的是没有骰子:/我尝试删除minHeight属性并将代码放入活动的主布局中,效果很好。这些参数可能有问题。