Добрый день всем! Делаю активити авторизации и у меня вопрос возник с разметкой.
Вот макет активити.
там получается есть фоновое изображение и белый блок с полями и надписями по центру экрана. Дак вот я сделал так: обернул один LinerLayout в другой LinerLayout. Наружнему задал gravity="center", а внутреннему ширину и высоту. Хочу по интересоваться у опытных, правильно ли я сделал? или надо было это сделать как-то иначе?
Вот сам код разметки
[syntax=xml]
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff000"
android:orientation="vertical"
android:gravity="center">
<LinearLayout
android:layout_width="280dp"
android:layout_height="350dp"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/email" />
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/email_ex"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pass" />
<EditText
android:id="@+id/pass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/your_pass"
android:inputType="numberPassword" />
<Button
android:id="@+id/btnGo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btn_login" />
<CheckBox
android:id="@+id/StayLoggedIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:focusable="false"
android:selectAllOnFocus="false"
android:text="@string/stay_logged_in" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
[/syntax]
Расположение элементов.
Re: Расположение элементов.
android:layout_width="280dp"
android:layout_height="350dp"
1) это уже не правильно, потому как если потестить на всех разрешениях то на каком то будет не красиво;
2) значения вида dp, sp, px, color, string нужно выносить в ресурсы;
P.S. обойтись можно было проще - задать главному LinearLayout padding.
android:layout_height="350dp"
1) это уже не правильно, потому как если потестить на всех разрешениях то на каком то будет не красиво;
2) значения вида dp, sp, px, color, string нужно выносить в ресурсы;
P.S. обойтись можно было проще - задать главному LinearLayout padding.
R.id.team
Политика на форуме запрещена
Политика на форуме запрещена
Re: Расположение элементов.
для этого давно есть замечательная статья
R.id.team
Политика на форуме запрещена
Политика на форуме запрещена