【问题标题】:Android Layout - Arc ButtonsAndroid 布局 - 弧形按钮
【发布时间】:2015-04-14 15:38:08
【问题描述】:

我想为一个应用制作一个这样的主页。问题是我没有得到我想要的完美曲线,而且这在其他屏幕上也不起作用。这是我使用的代码。

<?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>

这里是现在主页的链接Image 我想要的布局Image

【问题讨论】:

  • 您能否分享当前视图的屏幕截图或您尝试复制的内容的任何参考?
  • 曲线?什么曲线?你在说什么?
  • i.imgur.com/3ALwNMm.png?1这是首页i.imgur.com/CqSNpcO.png要复制的来源
  • 按钮布局中的曲线...一旦检查这些图像。

标签: android xml android-layout


【解决方案1】:

你使用了太多的视图和线性布局,这不是好的 UI 设计, 虽然您可以用单个 TextView 替换“按钮和 TextView”。

因此你可以试试这个布局。

<?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>

这个布局几乎就像你的布局一样,只有更少的线性布局和其他视图。

我希望这对你有所帮助。

【讨论】:

  • 复制粘贴我的布局,让我知道它对你有帮助。
  • 谢谢 A.R.为了帮助我。我是新手,所以这些就像减速带。还有一件事,我怎样才能移动线性布局?我希望它们像上图一样位于中心
  • 您可以在Linear Layout下使用android:gravity="center_horizo​​ntal",同时您需要根据您的要求调整其他textviews的“margin_left”。
猜你喜欢
  • 1970-01-01
  • 2011-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-13
  • 2013-03-09
  • 2011-12-17
  • 1970-01-01
相关资源
最近更新 更多