首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >线性布局用户界面设计

线性布局用户界面设计
EN

Stack Overflow用户
提问于 2014-04-08 18:02:34
回答 2查看 175关注 0票数 0

嗨,我是的新手,只有15岁。我一直在尝试制作一个UI设计,上面的红色框是图像按钮。我试过体重等,但每次它都会切断图像的边缘。

代码语言:javascript
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearlayout_01"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearlayout_02"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/squads"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:layout_weight="2"
            android:src="@drawable/squad" />

        <ImageButton
            android:id="@+id/results"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:layout_weight="2"
            android:src="@drawable/results" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearlayout_03"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/highlights"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:layout_weight="4"
            android:src="@drawable/highlights" />

        <ImageButton
            android:id="@+id/fixtures"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:layout_weight="4"
            android:src="@drawable/fixtures" />
    </LinearLayout>

</LinearLayout>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-04-08 18:57:59

试试这个布局结构,

代码语言:javascript
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearlayout_01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearlayout_02"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    >

    <ImageButton
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:src="@drawable/ic_launcher" />
</LinearLayout>

<LinearLayout
    android:id="@+id/linearlayout_03"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    >

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_weight="1"
        android:src="@drawable/ic_launcher" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="10dp"
        android:layout_weight="2"
        android:src="@drawable/ic_launcher" />
</LinearLayout>

<LinearLayout
    android:id="@+id/linearlayout_04"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
     >

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_weight="2"
        android:src="@drawable/ic_launcher" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="10dp"
        android:layout_weight="1"
        android:src="@drawable/ic_launcher" />
</LinearLayout>

 <LinearLayout
    android:id="@+id/linearlayout_05"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    >

    <ImageButton
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:src="@drawable/ic_launcher" />
</LinearLayout>

在这里,默认图像以ic_launcher的形式拍摄。

票数 1
EN

Stack Overflow用户

发布于 2014-04-08 18:11:43

如果您只需要可点击的图像,就不要使用ImageButtons,使用ImageViewclickable="true"。使用ImageView,您可以尝试不同的scaleType属性值来实现所需的功能。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22944810

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档