android 布局?

图片描述

其中用到了TableRow,把Button包在里面了,我想问一下怎么调整他们之间的距离,就是感觉之间空白太多了。
加粗文字
<?xml version="1.0" encoding="utf-8"?><!--发现首页面-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingTop="5dp">

    <!--此处是发现的首页-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="centerInside"
            android:src="@drawable/test" />

    </LinearLayout>
    <!-- 第一行-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <!--自动推上去的页面-->
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="*">

            <TableRow>

                <Button
                    android:id="@+id/find_btn_1"
                    android:layout_width="1dip"
                    android:layout_height="wrap_content" />

                <Button
                    android:id="@+id/find_btn_2"
                    android:layout_width="1dip"
                    android:layout_height="wrap_content"
                    android:text="test" />
            </TableRow>

            <TableRow>

                <Button
                    android:id="@+id/find_btn_3"
                    android:layout_width="1dip"
                    android:layout_height="wrap_content"
                    android:text="test" />

                <Button
                    android:id="@+id/find_btn_4"
                    android:layout_width="1dip"
                    android:layout_height="wrap_content"
                    android:text="test" />
            </TableRow>

            <TextView
                android:id="@+id/tv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </TableLayout>

    </LinearLayout>
    <!-- 第二行-->
    <!-- 热门新闻-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <Button
            android:id="@+id/find_hotnews"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="热门新闻/已经做了" />

        <Button
            android:id="@+id/btn_find_around"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="附件的新闻/好友" />

        <Button
            android:id="@+id/fin_btn_health"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="健康水平测试" />
    </LinearLayout>

</LinearLayout>

</ScrollView>

阅读 2.8k
2 个回答

外边距:

android:layout_margin=""
android:layout_marginRight=""
android:layout_marginLeft=""
android:layout_marginTop=""
android:layout_marginBottom=""

在Linearlayout里用weight控制充满布局,然后子widget设置margin
<Linearlayout
Orientation= horizontal
...>
<button
Layout width= 0dp
Layout weight= 1
...

<button

Layout width= 0dp
Layout weight= 1
Layout margin start= 10dp
...

</linearyout>
手机端只能打点伪代码出来了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题