建议改善我的布局

时间:2016-08-25 19:12:10

标签: android xml

我想改进我的应用程序的主页设计,但我不知道怎么做,我真的没有很好的设计技巧,有人可以给我一些建议。谢谢。

enter image description here

这是我对此页面的代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="#fff59d"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="ie.example.artur.projectrepeat.Main2Activity">




    <Button
        android:background="@drawable/sample"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:text="View All"
        android:id="@+id/view_all"

        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@+id/button_add"
        android:layout_toStartOf="@+id/button_add" />




    <Button
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:text="Add"
        android:id="@+id/button_add"
        android:layout_gravity="bottom"
        android:background="@drawable/sample"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@+id/editText_Number"
        android:layout_toEndOf="@+id/editText_Number" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText_Quantity"
        android:hint="@string/Enter_amount"
        android:layout_alignParentTop="true"
        android:layout_marginTop="123dp"
        android:inputType="number"
        />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText_Category"
        android:hint="@string/Enter_Product"
        android:inputType="textAutoCorrect"
        android:layout_below="@+id/editText_Quantity"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <!--<EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText_id"
        android:hint="@string/Enter_id"
        android:inputType="number"
        android:layout_below="@+id/editText_Category"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />-->

    <EditText
        android:textColor="#FF0000"
        android:layout_width="148dp"
        android:layout_height="56dp"
        android:id="@+id/editText_name"
        android:hint="@string/Enter_Name"
        android:layout_gravity="center_vertical"
        android:layout_above="@+id/editText_Category"
        android:layout_marginBottom="44dp"
        android:layout_alignLeft="@+id/editText_Quantity"
        android:layout_alignStart="@+id/editText_Quantity"
        android:inputType="text"
        android:layout_toLeftOf="@+id/button_add"
        android:layout_toStartOf="@+id/button_add"

        />

    <TextView

        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:background="@drawable/sample"
        android:gravity="center"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Please Choose your Product"
        android:id="@+id/textView"
        android:layout_gravity="center"

        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_above="@+id/editText_name" />

    <EditText
        android:hint="Importance of product"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText_Number"
        android:layout_below="@+id/editText_Category"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignRight="@+id/editText_Category"
        android:layout_alignEnd="@+id/editText_Category" />
    <![CDATA[

    SearchView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/searchView"
        android:layout_alignParentTop="true"
        android:layout_alignLeft="@+id/button_add"
        android:layout_alignStart="@+id/button_add"
        android:layout_alignRight="@+id/button_add"
        android:layout_alignEnd="@+id/button_add" />


]]>
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Please choose your product   "
    android:textColor="@color/white"
    android:theme="@style/MyButtonStack"
    android:layout_marginTop="5dp"
    android:textStyle="normal"
    android:drawableRight="@mipmap/ic_send_white_24dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="75px"
    android:id="@+id/button" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/MyHintText">
</android.support.design.widget.TextInputLayout>
<EditText
    android:layout_marginLeft="15px"
    android:layout_marginRight="15px"
    android:layout_marginBottom="50px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Enter product name"
    android:theme="@style/MyEditText"
    android:layout_below="@+id/button"
    android:layout_alignParentStart="true"
    android:id="@+id/editText2" />
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintTextAppearance="@style/MyHintText">
</android.support.design.widget.TextInputLayout>
<EditText
    android:layout_marginLeft="15px"
    android:layout_marginRight="15px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Enter quantity"
    android:layout_marginBottom="50px"
    android:theme="@style/MyEditText"
    android:layout_below="@+id/editText2"
    android:id="@+id/editText3" />
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintTextAppearance="@style/MyHintText">

</android.support.design.widget.TextInputLayout>
<EditText
    android:layout_marginLeft="15px"
    android:layout_marginRight="15px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Enter product category"
    android:theme="@style/MyEditText"
    android:layout_below="@+id/editText3"
    android:layout_marginBottom="50px"
    android:layout_centerHorizontal="true"
    android:id="@+id/editText4" />
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintTextAppearance="@style/MyHintText">

</android.support.design.widget.TextInputLayout>
<EditText
    android:layout_marginLeft="15px"
    android:layout_marginRight="15px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Enter product importance"
    android:theme="@style/MyEditText"
    android:layout_below="@+id/editText4"
    android:layout_centerHorizontal="true"
    android:id="@+id/editText5" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Add"
    android:textColor="@color/white"
    android:theme="@style/MyButtonStack"
    android:textStyle="normal"
    android:id="@+id/button1"
    android:layout_alignParentBottom="true"
    android:layout_alignEnd="@+id/editText5" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="View all"
    android:textColor="@color/white"
    android:theme="@style/MyButtonStack"
    android:textStyle="normal"
    android:id="@+id/button2"
    android:layout_alignParentBottom="true"
    android:layout_toStartOf="@+id/button1" />

<强>样式

<style name="MyButtonStack" parent="Theme.AppCompat.Light">
    <item name="colorControlHighlight">@color/indigo</item>
    <item name="colorButtonNormal">@color/active</item>
</style>
<!--Floating label text style-->
<style name="MyHintText" parent="TextAppearance.AppCompat.Small">
    <item name="android:textColor">@color/active</item>
</style>

<!--Input field style-->
<style name="MyEditText" parent="Theme.AppCompat.Light">
    <item name="colorControlNormal">@color/indigo</item>
    <item name="colorControlActivated">@color/colorPrimary</item>
</style>

您可以使用微调器替换类别字段,使用滑块/数字选择器替换数量 我建议使用谷歌的材料设计,按钮和什么不是 这些网站将指导设计一个全新的现代用户界面Material design docsGoogle's material design documentations和图标Material design icons