Holo中的Android按钮栏

DHa*_*ick 0 android android-layout

我正在创建一个在可用时使用Holo主题的Android应用程序,并在无法使用时回退到黑色主题.我通过完成此values,values-v11values-14文件夹.

我有一个活动,我想使用?android:attr/buttonBarStyle?android:attr/buttonBarButtonStyle风格,但我不确定如何在它们不可用时(例如@android:style/ButtonBar)回归到不同的风格.这是我的布局供参考.

<LinearLayout
    android:id="@+id/buttonArea"
    style="?android:attr/buttonBarStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:gravity="bottom|right"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button One" />

    <Button
        android:id="@+id/button2"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button Two" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

use*_*710 10

好吧,我有点晚了,但这就是我解决它的方法:

<LinearLayout
    android:id="@+id/footer"
    style="@style/ButtonBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/accountSpinner"
    android:orientation="horizontal" >

    <Button
        android:id="@android:id/button1"
        style="@style/ButtonBarButton"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="50dp"
        android:text="@string/login" />
    <Button
        android:id="@android:id/button2"
        style="@style/ButtonBarButton"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="50dp"
        android:enabled="false"
        android:text="@string/login" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这种风格:

<style name="ButtonBarButton">
</style>

<style name="ButtonBar" parent="@android:style/ButtonBar">
</style>
Run Code Online (Sandbox Code Playgroud)

对于v11:

<style name="ButtonBarButton" parent="@android:style/Widget.Holo.Button.Borderless">
    <item name="android:textColor">@android:color/primary_text_light</item>
</style>

<style name="ButtonBar" parent="@android:style/Holo.Light.ButtonBar.AlertDialog">
</style>
Run Code Online (Sandbox Code Playgroud)