-1

折断

            <RelativeLayout
            android:id="@+id/row1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@drawable/main_row" >

            <TextView
                android:id="@+id/alarm_clock"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:gravity="center_horizontal"
                android:text="7:15 AM"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="35dp" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/alarm_clock"
                android:layout_below="@+id/alarm_clock"
                android:layout_marginLeft="14dp"
                android:text="Next Alarm"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="29dp" />

            <TextView
                android:id="@+id/next_alarm_date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/alarm_clock"
                android:layout_below="@+id/textView2"
                android:layout_marginLeft="14dp"
                android:text="Thursday 27th July"
                android:textColor="#ffffff"
                android:textSize="19dp" />

            <TextView
                android:id="@+id/next_alarm_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/alarm_clock"
                android:layout_below="@+id/next_alarm_date"
                android:layout_marginLeft="14dp"
                android:text="8:05 AM"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="27sp" />

            <TextView
                android:id="@+id/next_alarm_time_left"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/alarm_clock"
                android:layout_below="@+id/next_alarm_time"
                android:layout_marginLeft="14dp"
                android:text="In 5 hrs 15 mins"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/add_alarm_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/next_alarm_time_left"
                android:layout_alignLeft="@+id/add_alarm_icon"
                android:layout_marginBottom="2dp"
                android:text="Add Alarm"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="13dp" />

            <ImageView
                android:id="@+id/add_alarm_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/add_alarm_text"
                android:layout_alignRight="@+id/alarm_clock"
                android:layout_marginRight="17dp"
                android:src="@drawable/add_alarm" />
        </RelativeLayout>

由于屏幕尺寸的原因,低于日期和日期的时间上午 8:05 超出了某些手机中的时钟图标。每当文本触摸时钟图标时,我怎么能做到这一点,剩余文本(时间)进入新行。

谢谢 :)

4

2 回答 2

0

好吧,我是自己做的:p

<RelativeLayout
            android:id="@+id/row1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@drawable/main_row" >

            <TextView
                android:id="@+id/alarm_clock"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:gravity="center_horizontal"
                android:text="7:15 AM"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="35dp" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@id/alarm_clock"
                android:layout_below="@id/alarm_clock"
                android:layout_marginLeft="14dp"
                android:text="Next Alarm"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="29dp" />

            <TextView
                android:id="@+id/next_alarm_date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@id/alarm_clock"
                android:layout_below="@id/textView2"
                android:layout_marginLeft="14dp"
                android:text="Thursday 27th July"
                android:textColor="#ffffff"
                android:textSize="19dp" />

            <TextView
                android:id="@+id/next_alarm_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@id/alarm_clock"
                android:layout_below="@id/next_alarm_date"
                android:layout_marginLeft="14dp"
                android:layout_toLeftOf="@+id/add_alarm_icon"
                android:text="8:05 AM"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="27sp" />

            <TextView
                android:id="@+id/next_alarm_time_left"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@id/alarm_clock"
                android:layout_below="@id/next_alarm_time"
                android:layout_marginLeft="14dp"
                android:text="In 5 hrs 15 mins"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />
            <ImageView
                android:id="@+id/add_alarm_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/add_alarm_text"
                android:layout_alignRight="@id/alarm_clock"
                android:layout_marginRight="17dp"
                android:src="@drawable/add_alarm" />

            <TextView
                android:id="@+id/add_alarm_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/next_alarm_time_left"
                android:layout_alignLeft="@id/add_alarm_icon"
                android:layout_marginBottom="2dp"
                android:text="Add Alarm"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="13dp" />


        </RelativeLayout>
于 2013-06-09T21:53:25.507 回答
0

你应该对你的布局进行一些改进,比如创建一个 color.xml 来设置颜色,创建一个 string.xml 来设置应用程序上使用的文本,而不是使用 dp 作为 textSize,使用 sp。

在此处查看一些构建用户界面的良好做法:http: //developer.android.com/guide/topics/ui/index.html

颜色.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <color name="white">#ffffff</color>
</resources>

字符串.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

   <string name="next_alarm_time_left">In 5 hrs 15 mins</string>
   <string name="add_alarm_text">Add Alarm</string>
   <string name="next_alarm_time">8:05 AM</string>
   <string name="next_alarm_date">Thursday 27th July</string>
   <string name="textView2">Next Alarm</string>
   <string name="alarm_clock">7:15 AM</string>

</resources>

布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/row1"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginTop="10dp">

  <TextView
   android:id="@+id/alarm_clock"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_alignParentTop="true"
   android:gravity="center_horizontal"
   android:text="@string/alarm_clock"
   android:textAppearance="?android:attr/textAppearanceLarge"
   android:textSize="35sp" />

  <TextView
   android:id="@+id/textView2"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignLeft="@+id/alarm_clock"
   android:layout_below="@+id/alarm_clock"
   android:layout_marginLeft="14dp"
   android:text="@string/textView2"
   android:textAppearance="?android:attr/textAppearanceMedium"
   android:textSize="29sp" />

  <TextView
   android:id="@+id/next_alarm_date"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignLeft="@+id/alarm_clock"
   android:layout_below="@+id/textView2"
   android:layout_marginLeft="14dp"
   android:text="@string/next_alarm_date"
   android:textColor="@color/white"
   android:textSize="19sp" />

  <TextView
   android:id="@+id/next_alarm_time"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignLeft="@+id/alarm_clock"
   android:layout_below="@+id/next_alarm_date"
   android:layout_marginLeft="14dp"
   android:text="@string/next_alarm_time"
   android:textAppearance="?android:attr/textAppearanceLarge"
   android:textSize="27sp" />

  <TextView
   android:id="@+id/next_alarm_time_left"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignLeft="@+id/alarm_clock"
   android:layout_below="@+id/next_alarm_time"
   android:layout_marginLeft="14dp"
   android:text="@string/next_alarm_time_left"
   android:textAppearance="?android:attr/textAppearanceMedium"
   android:textSize="20sp" />

  <TextView
   android:id="@+id/add_alarm_text"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignBottom="@+id/next_alarm_time_left"
   android:layout_alignLeft="@+id/add_alarm_icon"
   android:layout_marginBottom="2dp"
   android:text="@string/add_alarm_text"
   android:textAppearance="?android:attr/textAppearanceLarge"
   android:textSize="13sp" />

  <ImageView
   android:id="@+id/add_alarm_icon"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_above="@+id/add_alarm_text"
   android:layout_alignRight="@+id/alarm_clock"
   android:layout_marginRight="17dp" />

</RelativeLayout>
于 2013-06-10T02:26:59.777 回答