歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 在 Android 中如何放置text views和image view?

在 Android 中如何放置text views和image view?

日期:2017/3/1 10:00:54   编辑:Linux編程

原問題描述:

我想在Android應用中獲得以下的效果:

背景圖片我使用一個nine-patch png圖片。我用一個text view 來實現

但結果出來不是這個,應該怎麼辦?

解決方案:

用一個TextView?難道每次換內容的話都要弄那前、後和中間的空格?

  1. <RelativeLayout
  2. android:id="@+id/relativeLayout1"
  3. android:layout_height="50dp"
  4. android:layout_width="200dp"
  5. android:background=""@drawable/rowimage"" >
  6. <TextView
  7. android:id="@+id/textView1"
  8. android:text="TextView1"
  9. android:layout_height="wrap_content"
  10. android:layout_width="wrap_content"
  11. android:layout_marginLeft="10dp"
  12. android:layout_alignParentLeft="true"
  13. android:layout_centerVertical="true" />
  14. <TextView
  15. android:id="@+id/textView2"
  16. android:text="TextView2"
  17. android:layout_height="wrap_content"
  18. android:layout_width="wrap_content"
  19. android:layout_marginRight="10dp"
  20. android:layout_alignParentRight="true"
  21. android:layout_centerVertical="true" />
  22. </RelativeLayout>

更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11

Copyright © Linux教程網 All Rights Reserved