我的应用程序中有几十个按钮,并且样式继承自Widget.AppCompat.Button
。大多数按钮都有高程和状态更改动画。真棒。
令人敬畏的是,有些按钮没有任何额外的好处。
以下是其中一个工作按钮
的示例<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
仍可使用。我希望这些按钮在水平布局中具有状态动画和高程。 Aka我希望按钮占据相同的空间并且彼此相邻。我怎样才能做到这一点?
我正在使用appcompat 22.2.1
答案 0 :(得分:0)
我想问题出在您的活动主题!!!!
很高兴提到按钮采用活动主题的风格。 你能做的是:
定义一种风格:
<style name="ThemeMaterialButtonColor" parent="Base.Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/md_teal_500</item></style>
然后在xml中的按钮中添加:
应用程式:主题=&#34; @风格/ ThemeMaterialButtonColor&#34;