如何讓安卓(Android)子控件超出父控件的范圍顯示
先來看一張預(yù)覽圖:
廢話不多說,直接上代碼:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dp"
android:background="@mipmap/www" />
<LinearLayout
android:id="@+id/ll_bottom"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="#F8549D"
android:elevation="10dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
<RelativeLayout
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="bottom"
android:background="@drawable/bottom_bg_shape">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:src="@mipmap/icon_go" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
這張圖呢是我剛剛做的,效果是參考了酷狗音樂播放器來完成的,我想說明重點在底部的導(dǎo)航欄:如圖

再來一張反效果預(yù)覽圖:
如何使得藍(lán)色圓形的播放鍵的顯示越過粉色的范圍。當(dāng)然經(jīng)過合理的布局是可以達(dá)到這樣的效果的,但是卻有更簡單的方法。也就是在根布局的屬性中加入一個來自Android自身提供的屬性:
android:clipChildren="false"
屬性解釋和說明:
1、android:clipChildren的意思:是否限制子View在其范圍內(nèi)
2、可以通過android:layout_gravity控制超出的部分如何顯示。
3、只需在根節(jié)點設(shè)置android:clipChildren為false即可,默認(rèn)為true
總結(jié)
以上就是如何讓安卓(Android)子控件超出父控件的范圍顯示出來的全部內(nèi)容,大家學(xué)會了嗎?希望本文可以幫助到各位。
- android ListView內(nèi)數(shù)據(jù)的動態(tài)添加與刪除實例代碼
- Android實現(xiàn)ListView數(shù)據(jù)動態(tài)加載的方法
- Android實現(xiàn)listview動態(tài)加載數(shù)據(jù)分頁的兩種方法
- Android判斷touch事件點是否在view范圍內(nèi)的方法
- Android百度地圖poi范圍搜索
- 一看就懂的Android APP開發(fā)入門教程
- Android基礎(chǔ)之使用Fragment控制切換多個頁面
- 六款值得推薦的android(安卓)開源框架簡介
- Android應(yīng)用開發(fā)SharedPreferences存儲數(shù)據(jù)的使用方法
- Android實現(xiàn)動態(tài)定值范圍效果的控件
相關(guān)文章
Android Studio開發(fā)中Gradle各種常見報錯問題解決方案
這篇文章主要為大家介紹了Android Studio開發(fā)中Gradle各種常見報錯問題解決方案,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-12-12
Android編程實現(xiàn)為ListView創(chuàng)建上下文菜單(ContextMenu)的方法
這篇文章主要介紹了Android編程實現(xiàn)為ListView創(chuàng)建上下文菜單(ContextMenu)的方法,簡單分析了上下文菜單的功能及ListView創(chuàng)建上下文菜單(ContextMenu)的具體步驟與相關(guān)操作技巧,需要的朋友可以參考下2017-02-02
android監(jiān)控sim卡有沒有服務(wù)示例(sim卡管理)
android監(jiān)聽SIM卡有沒有服務(wù),可以使用android.telephony.PhoneStateListener類來實現(xiàn),下面是一個簡單的小例子,大家參考使用吧2014-01-01
Android搜索框(SearchView)的功能和用法詳解
這篇文章主要為大家詳細(xì)介紹了Android搜索框SearchView的功能和用法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05
Android自定義View實現(xiàn)音頻播放圓形進度條
這篇文章主要為大家詳細(xì)介紹了Android自定義View實現(xiàn)音頻播放圓形進度條,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-06-06
Android實現(xiàn)橫向無限循環(huán)滾動的單行彈幕效果
這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)橫向無限循環(huán)滾動的單行彈幕效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-06-06
Android控件FlowLikeView實現(xiàn)點贊動畫
這篇文章主要為大家詳細(xì)介紹了一個點贊動畫的優(yōu)雅控件FlowLikeView,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-06-06

