国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android中ImageView無法居中的問題解決方法

2020-04-11 12:12:47
字體:
來源:轉載
供稿:網友
代碼如下:
[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>


于是乎四處找資料尋求解決的方式,原來是父類視圖的屬性沒有設置的原因,將父類視圖設置為居中邊可解決,即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設計方面往往很小的細節,很簡單的問題,有的時候就是會讓你煩上好一陣子,不過自己動手多多設計經驗多了,解決起來就簡單鳥!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 从化市| 汶上县| 鄂托克前旗| 德惠市| 平阳县| 东乡| 怀柔区| 鄯善县| 山西省| 白城市| 阜康市| 体育| 龙泉市| 蓬溪县| 德清县| 长乐市| 安岳县| 高州市| 陇川县| 申扎县| 荆州市| 云梦县| 靖安县| 延津县| 尉犁县| 贵港市| 延津县| 延川县| 鄱阳县| 裕民县| 余姚市| 扎囊县| 正镶白旗| 手游| 兖州市| 同心县| 洪江市| 新泰市| 沁水县| 景洪市| 英德市|