最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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 Gradle多渠道打包的實(shí)現(xiàn)方法

    Android Gradle多渠道打包的實(shí)現(xiàn)方法

    這篇文章主要介紹了Android Gradle多渠道打包的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • 深入Android線程的相關(guān)問題解惑

    深入Android線程的相關(guān)問題解惑

    本篇文章是對(duì)Android線程的相關(guān)問題進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • Android使用Notification在狀態(tài)欄上顯示通知

    Android使用Notification在狀態(tài)欄上顯示通知

    這篇文章主要為大家詳細(xì)介紹了Android使用Notification在狀態(tài)欄上顯示通知,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • Android StickListView實(shí)現(xiàn)懸停效果

    Android StickListView實(shí)現(xiàn)懸停效果

    這篇文章主要介紹了Android StickListView實(shí)現(xiàn)懸停效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-06-06
  • 詳解Android圖表 MPAndroidChart折線圖

    詳解Android圖表 MPAndroidChart折線圖

    本篇文章主要介紹了Android圖表 MPAndroidChart折線圖,MPAndroidChart的功能很強(qiáng)大,非常具有實(shí)用價(jià)值,需要的朋友可以參考下。
    2016-12-12
  • Android 為L(zhǎng)istView添加分段標(biāo)頭的方法

    Android 為L(zhǎng)istView添加分段標(biāo)頭的方法

    下面小編就為大家?guī)硪黄狝ndroid 為L(zhǎng)istView添加分段標(biāo)頭的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-04-04
  • Kotlin之在Gradle中無參(no-arg)編譯器插件的使用詳解

    Kotlin之在Gradle中無參(no-arg)編譯器插件的使用詳解

    這篇文章主要介紹了Kotlin之在Gradle中無參(no-arg)編譯器插件的使用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 使用Android原生WebView+Highcharts實(shí)現(xiàn)可左右滑動(dòng)的折線圖

    使用Android原生WebView+Highcharts實(shí)現(xiàn)可左右滑動(dòng)的折線圖

    折線圖是Android開發(fā)中經(jīng)常會(huì)碰到的效果,但由于涉及自定義View的知識(shí),對(duì)許多剛?cè)腴T的小白來說會(huì)覺得很高深,下面這篇文章主要給大家介紹了關(guān)于如何使用Android原生WebView+Highcharts實(shí)現(xiàn)可左右滑動(dòng)的折線圖的相關(guān)資料,需要的朋友可以參考下
    2022-05-05
  • Android發(fā)送GET與POST請(qǐng)求的DEMO詳解

    Android發(fā)送GET與POST請(qǐng)求的DEMO詳解

    本篇文章是對(duì)Android發(fā)送GET與POST請(qǐng)求的DEMO進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • Android事件與手勢(shì)操作詳解

    Android事件與手勢(shì)操作詳解

    現(xiàn)在程序都是通過事件實(shí)現(xiàn)人機(jī)交互的。事件:用于對(duì)圖形界面的操作,有物理按鍵事件和觸摸屏事件兩大類。在Android組件中提供了事件處理的相關(guān)方法,如在View類中提供onTouchEvent()方法重寫觸摸屏事件,setOnTouchListener()方法為組件設(shè)置監(jiān)聽器來處理觸摸屏事件
    2022-12-12

最新評(píng)論

自贡市| 灵璧县| 方山县| 沅江市| 宜川县| 涪陵区| 牟定县| 葵青区| 兴义市| 永兴县| 沂源县| 岳西县| 娱乐| 六枝特区| 普定县| 海阳市| 侯马市| 江安县| 平潭县| 乌苏市| 桐柏县| 寿宁县| 临城县| 边坝县| 磐安县| 渭南市| 东兰县| 班戈县| 镇宁| 泰兴市| 玛纳斯县| 浦县| 平阳县| 北川| 龙游县| 汝南县| 武山县| 镇赉县| 简阳市| 平凉市| 惠东县|