【问题标题】:Using tablelayout in Realtivelayout在 Realtivelayout 中使用表格布局
【发布时间】:2013-01-17 15:18:30
【问题描述】:

我在获得以下布局时遇到问题,有人可以帮助获得以下布局吗?总背景应该是白色的。感谢任何帮助

下面是我的xml文件

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

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/askabud" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="5dp" >
    </LinearLayout>

    <EditText
        android:id="@+id/fbedittext"
        android:layout_width="250dp"
        android:layout_height="100dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:layout_marginTop="33dp"
        android:ems="10"
        android:gravity="top"
        android:hint="@string/saysomething"
        android:lines="6"
        android:paddingRight="5dp"
        android:scrollHorizontally="true" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/fbcancel" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/fbedittext"
        android:layout_toLeftOf="@+id/imageView2"
        android:src="@drawable/facebooks1" />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/fbedittext"
        android:layout_alignLeft="@+id/imageView3"
        android:layout_marginBottom="18dp"
        android:src="@drawable/people" />

</RelativeLayout>

有人可以建议我如何获得用于编辑文本和下拉菜单的圆角。谢谢

【问题讨论】:

  • 您可以为此发布您的 .xml 文件吗?
  • RelativeLayout 足以满足这种布局。
  • 在此处发布您的 xml 代码,以便我们查看问题所在...
  • 我不知道如何实现..正在寻找 xml 文件
  • @Abhjith 如何获得下拉菜单?

标签: android android-layout android-relativelayout tablelayout


【解决方案1】:

对于editext的圆角,您可以在drawables文件夹中定义一个roundcorner.xml

<corners android:radius="14dp" />

然后在您的 xml 中将此作为编辑文本的背景。

android:background="@drawable/roundcorner"

检查此下拉菜单http://developer.android.com/guide/topics/ui/controls/spinner.html

【讨论】:

【解决方案2】:

检查我在您的代码中所做的更改:

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

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_launcher" />

    <EditText
        android:id="@+id/fbedittext"
        android:layout_width="250dp"
        android:layout_height="140dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:layout_marginTop="33dp"
        android:ems="10"
        android:gravity="top"
        android:hint="saysomething"
        android:lines="6"
        android:paddingRight="5dp"
        android:scrollHorizontally="true" />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="130dp"
        android:layout_alignBaseline="@id/fbedittext"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dip"
        android:layout_toRightOf="@id/fbedittexts" >

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:src="@drawable/ic_launcher" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:src="@drawable/ic_launcher" />
    </RelativeLayout>

    <Spinner
        android:id="@+id/spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/fbedittext" />

</RelativeLayout>

您不需要线性布局。您可以使用android:layout_marginRight 来设置右角的间距。 对于下拉菜单,您可以使用Spinner

【讨论】:

  • 非常感谢..是的,微调器是唯一的选择
猜你喜欢
  • 1970-01-01
  • 2017-01-18
  • 2011-10-28
  • 2013-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多