Android的UI风格材料 [英] android UI material style

查看:196
本文介绍了Android的UI风格材料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目的是做这样的事情:

My intention is to do something like this:

在两个视图中间的按钮。

with a button in the middle of the two views.

我跟着几个指令,但没有成功。
目前我有这在我的XML

I followed several instructions, but without success. Currently I have this in my xml

和我说过,我试图让这样的事情:

And as I said, I try to get something like this:

我已经做了很多测试,但不能得到的目标。

I have done many tests, but can not get the goal.

这是我使用的XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background">

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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/up"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/room" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/center"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_below="@+id/up"
                android:background="#f42323"
                android:orientation="vertical">


            </LinearLayout>

            <LinearLayout
                android:id="@+id/bottom"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/center"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla " />

            </LinearLayout>

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/up"
                android:drawableLeft="@drawable/ic_launcher"
                android:text="Hello!!" />

        </RelativeLayout>
    </LinearLayout>

</FrameLayout>

AP preciate帮助

appreciate the help

感谢和问候。

推荐答案

你想要的是使用 RelativeLayout的

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background">

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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/up"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/room" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/center"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_below="@+id/up"
                android:background="#f42323"
                android:orientation="vertical">


            </LinearLayout>

            <LinearLayout
                android:id="@+id/bottom"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/center"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla " />

            </LinearLayout>

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/up"
                android:drawableLeft="@drawable/ic_launcher"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="-25dp"
                android:layout_marginRight="8dp"
                android:text="Hello!!" />

        </RelativeLayout>
    </LinearLayout>

</FrameLayout>

您对齐底部页眉或顶面布置图。然后使用 marginBottom 回去一半按钮的大小:例如:-25
这应该这样做!

You align the bottom with your header or top layout. Then use marginBottom to go back half the size of the button: for example: -25 This should do it!

如果你也想在这里浮动操作按钮是我目前使用的库: https://开头github上。 COM / makovkastar / FloatingActionButton

If you also want the Floating Action Button here is a library I'm currently using: https://github.com/makovkastar/FloatingActionButton

这篇关于Android的UI风格材料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆