简体   繁体   English

Android布局-弧形按钮

[英]Android Layout - Arc Buttons

I wanted to make a home page like this for an app. 我想为应用创建一个这样的主页。 The problem is I am not getting the perfect curve which I want, and also this this does not work on other screens. 问题是我没有获得想要的完美曲线,而且这在其他屏幕上也无法使用。 This is the code which I have used. 这是我使用的代码。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/Background"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout3"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="5dp">
    <TextView
        android:text="Mind and Wellness"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/textView1"
        android:textColor="#ff3e4095"
        android:textColorHighlight="#ffffffff" />
</LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:layout_marginTop="35dp">
    <Space
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/space1"
        android:layout_weight="1.5" />
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout2"
        android:layout_weight="2">
        <Button
            android:id="@+id/button1"
            android:background="@drawable/buttonx"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="Find a Solution"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/textView1"
            android:textColor="#ff3e4095"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:layout_marginTop="12dp">
    <Space
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/space1"
        android:layout_weight="3" />
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout2"
        android:layout_weight="2">
        <Button
            android:id="@+id/button1"
            android:background="@drawable/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="Tips and Research"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/textView1"
            android:textColor="#ff3e4095"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:layout_marginTop="12dp">
    <Space
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/space1"
        android:layout_weight="4.5" />
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout2"
        android:layout_weight="1.5">
        <Button
            android:id="@+id/button1"
            android:background="@drawable/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="Mtyhs and Facts"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/textView1"
            android:textColor="#ff3e4095"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:layout_marginTop="12dp">
    <Space
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/space1"
        android:layout_weight="6" />
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout2"
        android:layout_weight="1.5">
        <Button
            android:id="@+id/button1"
            android:background="@drawable/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="Assesments"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/textView1"
            android:textColor="#ff3e4095"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:layout_marginTop="12dp">
    <Space
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/space1"
        android:layout_weight="7.5" />
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout2"
        android:layout_weight="1.5">
        <Button
            android:id="@+id/button1"
            android:background="@drawable/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="Distress"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/textView1"
            android:textColor="#ff3e4095"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:layout_marginTop="12dp">
    <Space
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/space1"
        android:layout_weight="9" />
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout2"
        android:layout_weight="2">
        <Button
            android:id="@+id/button1"
            android:background="@drawable/button5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="Articles"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/textView1"
            android:textColor="#ff3e4095"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>

Here is a link to the homepage right now Image The layout which i want Image 现在是主页的链接Image我想要的布局Image

You are using too many views and linear layouts which is not good UI Designing, Although you can replace your "Button and TextView" with single TextView. 尽管您可以使用单个TextView替换“ Button and TextView”,但您使用的视图和线性布局过多,这不是UI设计的好方法。

Therefore you can try this layout. 因此,您可以尝试这种布局。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/ic_launcher"
        android:gravity="top"
        android:text="Find a solution" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="45dp"
        android:drawableLeft="@drawable/ic_launcher"
        android:gravity="top"
        android:text="Tips &amp; Research" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="75dp"
        android:drawableLeft="@drawable/ic_launcher"
        android:gravity="top"
        android:text="Myths &amp; Facts" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="95dp"
        android:drawableLeft="@drawable/ic_launcher"
        android:gravity="top"
        android:text="Assesments" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="110dp"
        android:drawableLeft="@drawable/ic_launcher"
        android:gravity="top"
        android:text="Distress" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="115dp"
        android:drawableLeft="@drawable/ic_launcher"
        android:gravity="top"
        android:text="Articles" />

</LinearLayout>

This layout is almost like your layout with less number of Linear Layouts and other Views. 这种布局几乎就像您的布局,线性布局和其他视图的数量更少。

I Hope this helps you somehow. 我希望这可以对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM