Android之界面(布局文件layput)

1。关于组件居中

 ① android:layout_gravity="center"
控件在包含该控件的父控件中的位置。同样,当我们在Button按钮控件中设置android:layout_gravity="left"属性时,表示该Button按钮将位于界面的左部。
②android:scaleType="center"截取图片中间显示 
③   android:scaleType="centerInside"
复制代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
   
    >

    <TextView 
        android:id="@+id/tv_title"
           android:layout_width="match_parent"
           android:layout_height="0dp"
           android:layout_weight="1"
           android:text="个人中心"
           android:gravity="center"
           android:textSize="30px"
           android:background="#44cef6"
     />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="4"
            android:gravity="center"
        >
            <ImageView
                android:id="@+id/img_me"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:src="@drawable/ic_launcher" />
        </LinearLayout>
        
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="5"
        >
            <GridView
                android:id="@+id/person_grid_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:numColumns="3" 
                android:stretchMode="columnWidth">
            </GridView>
    
        </LinearLayout>
</LinearLayout>
复制代码

 

 
posted @   陈晓猛  阅读(1298)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示