- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个简单的相对布局 - 一个 ImageView (iv1) 和一个位于 iv1 左侧的 TextView (tv1)。不幸的是,我看不到 tv1。更何况,hierarchyViewer 也帮不了我。
<?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="wrap_content"
android:gravity="right"
android:background="@android:color/white"
>
<ImageView
android:id="@+id/iv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/tv1"
android:layout_toLeftOf="@+id/iv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</RelativeLayout>
看起来像这样:
但是,如果我将 android:layout_toLeftOf="@+id/iv1"更改为 android:layout_toRightOf="@+id/iv1",我的 TextView 将位于 ImageView 的右侧。似乎 toRightOf 有效而 toLeftOf 无效。这是它的样子:
怎么了?如何使 layout_toLeftOf 起作用?
最佳答案
改变:
<TextView
android:id="@+id/tv1"
android:layout_toLeftOf="@+id/+iv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
到:
<TextView
android:id="@+id/tv1"
android:layout_toLeftOf="@id/iv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
您在 TextView 的 toLeftOf 中使用 @+id/iv1 而不是 @id/iv1。您还应该在 View 中为 imageview 指定一个特定位置。尝试对齐它:layout_parentTop = true
关于android - layout_toRightOf 有效而 layout_toLeftOf 无效,如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9207969/
使用 Eclipse GUI 编辑布局后,我遇到了一个奇怪的问题。它告诉我找不到资源 tvVersionLabel。有什么明显的吗? 最佳答案 改变这个: andr
我在这里开发了一个应用程序。在这里我希望需要 o/p 如下格式: Artist: artist Duration: duration Title: title. 但是我得到
我试图并排设置两个 TextView : userVideouploaderTextView userVideoviewsTextView 但是,如果我设置 userVideouploaderText
我有一个简单的相对布局 - 一个 ImageView (iv1) 和一个位于 iv1 左侧的 TextView (tv1)。不幸的是,我看不到 tv1。更何况,hierarchyViewer 也帮不了
我想以编程方式设置这些属性:- android:layout_toEndOf="@+id/imageView1" android:layout_toRightOf="@+id/imageView1"
android:layout_alignRight="@id/someId" 和 android:layout_toRightOf="@id/someId" 有什么区别? 最佳答案 这张图片将解释不同
我有以下示例:一个 edittext 和右边的一个 imagebutton。我现在唯一的解决方案是针对 4"屏幕进行设计。 所以在 4"屏幕上的样子是这样的: 和 4.7"屏幕: 是否有解决方案可以将
我正在尝试配置三个 fragment :一个在左侧具有固定宽度,一个在右侧具有固定宽度,一个在中间会占用所有剩余空间。我搜索了一个解决方案,并遵循了我在网上找到的建议,但是当我尝试运行该应用程序时,出
我是一名优秀的程序员,十分优秀!