小技巧

1.判断EditText没有数据的时候,代码为

edit.getText().toString().equals("");

2.布局需要图片和文字,其中图片在左对齐,而文字的宽度不固定。此时可以在中间设置一个view,置宽度为1.

View Code
 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     android:layout_width="match_parent"
 3     android:layout_height="@dimen/largeMarginSides"
 4     android:gravity="center" >
 5     <TextView
 6         android:id="@+id/textView1"
 7         android:layout_width="1dp"
 8         android:layout_height="wrap_content"
 9         android:layout_alignTop="@+id/imageView1"
10         android:layout_centerHorizontal="true"
11         android:background="@null"
12         android:text="@null" />
13     <ImageView
14         android:id="@+id/imageView1"
15         android:layout_width="wrap_content"
16         android:layout_height="wrap_content"
17         android:layout_alignParentTop="true"
18         android:layout_toLeftOf="@+id/textView1"
19         android:contentDescription="@string/app_name"
20         android:src="@drawable/house" />
21     <TextView
22         android:id="@+id/type_info"
23         android:layout_width="wrap_content"
24         android:layout_height="wrap_content"
25         android:layout_alignBottom="@+id/imageView1"
26         android:layout_alignTop="@+id/textView1"
27         android:layout_toRightOf="@+id/imageView1"
28         android:gravity="center_vertical" />
29 </RelativeLayout>

 

posted on 2013-01-22 15:18  eelephant  阅读(108)  评论(0编辑  收藏  举报