亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android應(yīng)用的LinearLayout中嵌套R(shí)elativeLayout的布局用法

 更新時(shí)間:2016年04月13日 15:46:14   作者:xc0415  
這篇文章主要介紹了Android應(yīng)用的LinearLayout中嵌套R(shí)elativeLayout的布局用法,文后還給出了線性布局中一些組件位置的調(diào)試經(jīng)驗(yàn),需要的朋友可以參考下

想將Button和ListView分別放在屏幕的一左一右。
單純使用android:gravity和android:layout_gravity不成功。
于是涉及到RelativeLayout。
關(guān)鍵為:android:layout_alignParentRight="true",
android:layout_alignParentLeft="true":

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  android:orientation="vertical" android:layout_width="fill_parent"  
  android:layout_height="wrap_content" android:gravity="center_vertical"> 
 
  <TextView 
    android:id="@+id/mTextView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" /> 
 
   <RelativeLayout 
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content" android:gravity="right"  
    android:padding="10dp"> 
    <TextView 
      android:id="@+id/mTextView01" 
      android:layout_alignParentLeft="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="范例一" /> 
    <Button 
      android:id="@+id/mButton01" 
      android:layout_alignParentRight="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="發(fā)送" /> 
    </RelativeLayout> 
 
    <RelativeLayout 
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content" android:gravity="right"  
    android:padding="10dp"> 
    <TextView 
      android:id="@+id/mTextView02" 
      android:layout_alignParentLeft="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="范例二" /> 
    <Button 
      android:id="@+id/mButton01" 
      android:layout_alignParentRight="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="發(fā)送" /> 
    </RelativeLayout> 
</LinearLayout> 

效果為:

2016413154429622.png (332×182)

PS:另附我的項(xiàng)目布局的一點(diǎn)經(jīng)驗(yàn)

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:orientation="vertical"> 
 
  <LinearLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_marginLeft="50px" 
    android:layout_marginRight="50px" 
    android:layout_marginBottom="15px" 
    android:layout_gravity="center" 
    android:gravity="center">  
    <TextView  
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="性別" 
      android:textSize="18sp" 
      android:layout_weight="3"/>     
     <RadioGroup android:id="@+id/radioGroup"  
       android:contentDescription="性別"  
       android:layout_width="fill_parent"  
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:layout_weight="1"> 
          
      <RadioButton android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:id="@+id/radioMale"  
        android:text="男"  
        android:checked="true" 
        android:layout_marginRight="15px" 
        android:textSize="18sp"> 
        </RadioButton> 
      <RadioButton android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:id="@+id/radioFemale"  
        android:text="女" 
        android:textSize="18sp"> 
        </RadioButton> 
     </RadioGroup> 
 </LinearLayout> 
   
</LinearLayout> 

 開始時(shí)RadioGroup的layout_width="wrap_content",怎么設(shè)置權(quán)都達(dá)不到想要的效果。要改成fill_parent
RadioButton的尺寸比TextView大  所以顯示時(shí)TextView在上方,設(shè)置LinearLayout中android:gravity="center">即可。

相關(guān)文章

  • Android Activity中使用Intent實(shí)現(xiàn)頁面跳轉(zhuǎn)與參數(shù)傳遞的方法

    Android Activity中使用Intent實(shí)現(xiàn)頁面跳轉(zhuǎn)與參數(shù)傳遞的方法

    這篇文章主要介紹了Android Activity中使用Intent實(shí)現(xiàn)頁面跳轉(zhuǎn)與參數(shù)傳遞的方法,結(jié)合實(shí)例形式簡單分析了Android中的Activity交互操作相關(guān)技巧,需要的朋友可以參考下
    2016-07-07
  • Android開發(fā)Compose集成高德地圖實(shí)例

    Android開發(fā)Compose集成高德地圖實(shí)例

    這篇文章主要為大家介紹了Android開發(fā)Compose里使用高德地圖實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-08-08
  • Android 中WallpaperManager用法實(shí)例

    Android 中WallpaperManager用法實(shí)例

    這篇文章主要介紹了Android 中WallpaperManager用法實(shí)例的相關(guān)資料,希望通過本文能幫助到大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下
    2017-09-09
  • Android開發(fā)之自定義刮刮卡實(shí)現(xiàn)代碼

    Android開發(fā)之自定義刮刮卡實(shí)現(xiàn)代碼

    本篇文章主要介紹了Android開發(fā)之自定義刮刮卡實(shí)現(xiàn)代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-07-07
  • Android SeekBar在刷新使用中需要注意的問題

    Android SeekBar在刷新使用中需要注意的問題

    SeekBar在刷新使用中需要注意的問題:在使用SeekBar的過程中需要注意刷新頻率,避免頻繁刷新造成的性能問題;同時(shí),需要對(duì)SeekBar的監(jiān)聽事件進(jìn)行適當(dāng)?shù)膬?yōu)化,減少回調(diào)次數(shù),提高響應(yīng)速度
    2023-05-05
  • Android實(shí)現(xiàn)Bitmap位圖旋轉(zhuǎn)效果

    Android實(shí)現(xiàn)Bitmap位圖旋轉(zhuǎn)效果

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)Bitmap位圖旋轉(zhuǎn)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • Android中CountDownTimer 實(shí)現(xiàn)倒計(jì)時(shí)功能

    Android中CountDownTimer 實(shí)現(xiàn)倒計(jì)時(shí)功能

    本篇文章主要介紹了Android中CountDownTimer 實(shí)現(xiàn)倒計(jì)時(shí)功能,CountDownTimer 是android 自帶的一個(gè)倒計(jì)時(shí)類,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Flutter實(shí)現(xiàn)仿微信分享功能的示例代碼

    Flutter實(shí)現(xiàn)仿微信分享功能的示例代碼

    Flutter 用來快速開發(fā) Android iOS平臺(tái)應(yīng)用,在Flutter 中,通過 fluwx或者fluwx_no_pay 插件可以實(shí)現(xiàn)微信分享功能,本文將具體介紹實(shí)現(xiàn)的示例代碼,需要的可以參考一下
    2022-01-01
  • android換膚功能 如何動(dòng)態(tài)獲取控件中背景圖片的資源id?

    android換膚功能 如何動(dòng)態(tài)獲取控件中背景圖片的資源id?

    這篇文章主要為大家詳細(xì)介紹了android換膚功能中如何動(dòng)態(tài)獲取控件中背景圖片的資源id? ,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-08-08
  • 詳解Flutter如何完全自定義TabBar

    詳解Flutter如何完全自定義TabBar

    在App中TabBar形式交互是非常常見的,但是系統(tǒng)提供的的樣式大多數(shù)又不能滿足我們產(chǎn)品和UI的想法,本文記錄了在Flutter中如何實(shí)現(xiàn)自定義TabBar的一個(gè)思路和過程,需要的可以參考一下
    2022-04-04

最新評(píng)論