Jak Android Holo Theme style okno dialogowe przyciski
Tworzę okno dialogowe na temat Holo i chcę podążać za domyślnym sposobem wyświetlania przycisków. Do tej pory stworzyłem okno dialogowe, ale przyciski nie renderują się tak, jak to robi w aplikacjach wykonanych w Holo dla ICS. Jak mogę to zrobić? Moim zamierzonym wyglądem jest i jestem w stanie sięgnąć aż tutaj
3 answers
Trochę za późno, ale może ktoś nadal jest tym zainteresowany.
To mi pasuje....
<!--
EDIT: be carefull, "?android:attr/dividerHorizontal" is only supported since API 11
just avoid it in prior OSs.
-->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="0dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:measureWithLargestChild="true">
<Button
android:id="@+id/cancel"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@android:string/cancel"/>
<Button
android:id="@+id/ok"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@android:string/ok"/>
</LinearLayout>
...
Czynność, która ładuje ten układ, wymaga Holo.Motyw dialogowy.
android:theme="@android:style/Theme.Holo.Dialog"
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-05 10:31:48
To działa:
<LinearLayout
android:id="@+id/buttonHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/cmdSignup"
style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/Signup" />
<Button
android:id="@+id/cmdLogin"
style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/Login" />
</LinearLayout>
Właściwość style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
nadaje płaski wygląd, a rozkład wagi 50% jest spowodowany połączeniem 100$ rozmiaru LinearLayout
przez android:layout_width="match_parent" and
android:layout_weight="1"`dla przycisków
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-21 17:23:32
Możesz ustawić motyw za pomocą manifestu XML Androida lub wewnątrz OnCreate aktywności za pomocą setTheme(android.R.style.Theme_Holo);
Rozmiar przycisków nie jest związany z samym motywem. Rozmiar zależy od definicji xml. Na zdjęciu, które wysłałeś, wygląda na to, że przyciski otrzymały motyw Holo, więc nie ma tu nic złego...
Oto układ xml, który rozciągnie przyciski, aby wypełnić całą szerokość okna dialogowego:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
>
<Button
android:id="@+id/okButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="OK"
/>
<Button
android:id="@+id/cancelButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"
/>
</LinearLayout>
</LinearLayout>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-21 17:06:07