【发布时间】:2017-02-01 06:53:14
【问题描述】:
我有以下布局。我希望 id 为 tvName 的 textView 位于左上角,而 id 为 tvAddress 的 textView 位于屏幕的右上角,如下所示
电视名称电视地址
在下面的代码中,我使用了 layout_gravity 属性,但它没有达到我想要的效果
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"/>
<TextView
android:id="@+id/tvAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Address: "/>
</LinearLayout>
【问题讨论】:
-
您可以添加所需设计的图片吗?
-
在 LinearLayout 中使用 layout_gravity
-
切换您的布局使用相对布局或向我们展示您得到什么以及您需要什么,以便我们为您提供帮助
标签: android android-layout layout android-linearlayout