Android中ImageView無(wú)法居中的問(wèn)題解決方法
[java]
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:padding="20dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="108dp"
android:layout_height="108dp"
android:orientation="vertical"
android:background="#3399ff">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:src="@drawable/menu_icon__mail"
android:layout_gravity="center"/>
</LinearLayout>
于是乎四處找資料尋求解決的方式,原來(lái)是父類視圖的屬性沒(méi)有設(shè)置的原因,將父類視圖設(shè)置為居中邊可解決,即android:gravity="center":
[java]
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:padding="20dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="108dp"
android:layout_height="108dp"
android:orientation="vertical"
android:gravity="center"
android:background="#3399ff">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:src="@drawable/menu_icon__mail"
android:layout_gravity="center"/>
</LinearLayout>
UI設(shè)計(jì)方面往往很小的細(xì)節(jié),很簡(jiǎn)單的問(wèn)題,有的時(shí)候就是會(huì)讓你煩上好一陣子,不過(guò)自己動(dòng)手多多設(shè)計(jì)經(jīng)驗(yàn)多了,解決起來(lái)就簡(jiǎn)單鳥(niǎo)!
相關(guān)文章
Android6.0獲取GPS定位和獲取位置權(quán)限和位置信息的方法
今天小編就為大家分享一篇Android6.0獲取GPS定位和獲取位置權(quán)限和位置信息的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-07-07Android開(kāi)發(fā)疫情查詢app(實(shí)例代碼)
這篇文章主要介紹了用Android開(kāi)發(fā)一個(gè)疫情查詢的APP,文中代碼非常詳細(xì),供大家參考和學(xué)習(xí),感興趣的朋友可以了解下2020-06-06Android TextView字體顏色設(shè)置方法小結(jié)
這篇文章主要介紹了Android TextView字體顏色設(shè)置方法,結(jié)合實(shí)例形式總結(jié)分析了Android開(kāi)發(fā)中TextView設(shè)置字體顏色的常用技巧,需要的朋友可以參考下2016-02-02RecyclerView實(shí)現(xiàn)水波紋點(diǎn)擊效果
這篇文章主要為大家詳細(xì)介紹了RecyclerView實(shí)現(xiàn)水波紋點(diǎn)擊效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01linphone-sdk-android版本號(hào)生成解析
這篇文章主要為大家介紹了linphone-sdk-android版本號(hào)生成解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09Android開(kāi)發(fā)筆記之:對(duì)實(shí)踐TDD的一些建議說(shuō)明
本篇文章是對(duì)Android中實(shí)踐TDD的一些建議進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05Android使用AudioRecord實(shí)現(xiàn)錄音功能
這篇文章主要為大家詳細(xì)介紹了Android使用AudioRecord實(shí)現(xiàn)錄音功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08教你3分鐘了解Android 簡(jiǎn)易時(shí)間軸的實(shí)現(xiàn)方法
本篇文章主要介紹了教你3分鐘了解Android 簡(jiǎn)易時(shí)間軸的實(shí)現(xiàn)方法,具有一定的參考價(jià)值,有興趣的可以了解一下2017-07-07android?studio實(shí)驗(yàn):?UI設(shè)計(jì)?ListView及事件響應(yīng)
這篇文章主要介紹了android?studio實(shí)驗(yàn):?UI設(shè)計(jì)?ListView及事件響應(yīng),主要是ListView及其事件響應(yīng)方法?彈出菜單PopupMenu及其事件響應(yīng)方法,下面來(lái)看看具文章體的介紹吧2021-12-12