проблема с пользовательским интерфейсом Android - PullRequest
0 голосов
/ 15 июня 2011

Ниже приводится изображение пользовательского интерфейса. Когда приложение запускается, оно выглядит следующим образом enter image description here

в этом я показываю изменения в таймере и изменении км. Когда километры меняются, мое расположение нарушается следующим образом

enter image description here

Ниже приведен макет моего интерфейса

<LinearLayout android:id="@+id/linearLayout2"  android:background="@drawable/rounded_background" android:layout_width="fill_parent" android:layout_height="wrap_content"  android:layout_marginTop="50dip"
                          android:layout_marginLeft="15dip" android:layout_marginRight="15dip" android:orientation="vertical">

                <LinearLayout android:id="@+id/linearLayout3"  android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">        
                       <TextView android:text="00:00:00" android:id="@+id/timer"  android:textSize="28dip" android:gravity="center_vertical|center_horizontal" android:textColor="#000000"
                                 android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="15dip" android:layout_marginBottom="15dip">
                        </TextView>
                </LinearLayout>

                <View android:id="@+id/separator1" android:background="#000000" android:layout_width = "fill_parent" android:layout_height="1dip" android:layout_centerVertical ="true" android:layout_alignParentTop="true"/>

                <LinearLayout android:id="@+id/linearLayout4" android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="wrap_content">
                    <LinearLayout android:layout_marginLeft="55dip" android:id="@+id/linearLayout5" android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="wrap_content">
                            <TextView android:text="0" android:id="@+id/pace"  android:textSize="17dip"  android:textColor="#000000" android:layout_marginBottom="5dip" android:layout_weight="1"
                                      android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="15dip" android:lines="1" android:gravity="right" >
                            </TextView>
                            <TextView android:text="Km/hr" android:id="@+id/pace1" android:layout_width="wrap_content" android:layout_height="wrap_content" 
                                      android:lines="1" android:textColor="#000000"  android:layout_marginLeft="7dip" android:layout_marginTop="15dip" android:layout_marginBottom="15dip">
                            </TextView>
                    </LinearLayout>           

                    <View android:id="@+id/separator2" android:layout_marginLeft="40dip" android:layout_width="1dip" android:layout_height="fill_parent"  android:background="#000000" />

                    <LinearLayout android:id="@+id/linearLayout6" android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="wrap_content">
                            <TextView android:text="0" android:id="@+id/cal"  android:textSize="20dip"  android:textColor="#000000" android:layout_marginBottom="5dip"
                                      android:layout_marginLeft="25dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="15dip">  
                            </TextView>
                            <TextView android:text="cal" android:id="@+id/cal1" android:layout_width="wrap_content" android:layout_height="wrap_content" 
                                      android:textColor="#000000"  android:layout_marginLeft="15dip" android:layout_marginTop="15dip" android:layout_marginBottom="5dip">               
                            </TextView>
                    </LinearLayout>    
                </LinearLayout>       

Я не хочу, чтобы мой пользовательский интерфейс был нарушен, как это сделать, пожалуйста, помогите мне, друзья ......

Ответы [ 5 ]

1 голос
/ 15 июня 2011

U должен установить Layout_Width="50dip" или некоторую константу ... если вы говорите это как перенос содержимого, это делает это, и макет становится нарушенным ... Я говорю о 2 текстовых представлениях, которые имеют km и cal ..

0 голосов
/ 15 июня 2011

почему бы вам не использовать один RelativeLayout для эффективности

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="125dp">
    <TextView android:text="00:00:00" android:id="@+id/timer"
        android:textSize="28dp" android:gravity="center_vertical|center_horizontal"
        android:textColor="#000000" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginTop="15dp"
        android:layout_marginBottom="15dp" />
    <View android:id="@+id/separator1" android:background="#000000"
        android:layout_width="fill_parent" android:layout_height="1dp"
        android:layout_below="@+id/timer" android:layout_marginRight="15dp"
        android:layout_marginLeft="15dp" />
    <TextView android:text="cal" android:id="@+id/cal1"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:textColor="#000000" android:layout_marginRight="15dp"
        android:layout_marginTop="20dp" android:layout_marginBottom="15dp"
        android:layout_alignParentRight="true" android:layout_below="@+id/separator1" />
    <TextView android:text="0" android:id="@+id/cal"
        android:textSize="20dp" android:textColor="#000000"
        android:layout_marginRight="7dp" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_toLeftOf="@+id/cal1"
        android:layout_alignBaseline="@+id/cal1" />
    <View android:id="@+id/separator2"
        android:layout_alignParentRight="true" android:layout_marginRight="100dp"
        android:layout_width="1dp" android:layout_height="fill_parent"
        android:layout_marginBottom="15dp" android:layout_below="@+id/separator1"
        android:background="#000000" />
    <TextView android:text="Km/hr" android:id="@+id/pace1"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:textColor="#000000" android:layout_marginRight="7dp"
        android:layout_alignBaseline="@+id/cal1" android:layout_toLeftOf="@+id/separator2" />
    <TextView android:text="0" android:id="@+id/pace"
        android:textSize="17dp" android:textColor="#000000"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_marginRight="7dp" android:layout_alignBaseline="@+id/cal1"
        android:layout_toLeftOf="@+id/pace1" />
</RelativeLayout>
0 голосов
/ 15 июня 2011

Используйте строку таблицы ниже для linearLayout2.В этой строке таблицы используйте два линейных макета с вертикальной ориентацией.Для первого фиксированного линейного макета его ширина. Затем поместите вид после первого линейного макета, а затем второго линейного макета.TextView1 в первом линейном макете для сообщения и textview2 в линейном lay2.

0 голосов
/ 15 июня 2011

Текст ваших просмотров центрируется вручную по краю.Этот подход не является гибким, как вы можете видеть.Я бы убрал эти поля и вместо этого установил landroid:layout_gravity="center".Кроме того, вы должны установить android:layout_weight для ваших TextView s cal и cal1 как 0.6 и 0.4 соответственно.Немного измените вес, если он вам не подходит.

0 голосов
/ 15 июня 2011

Назначьте одинаковые layout_weight для linearLayout5 и linearLayout6.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...