[英]set imageview width match textview width
i want to achieve this 我想实现这一目标
here is my layout 这是我的布局
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/black">
<ImageView
android:id="@+id/imf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/frame001"
/>
<TextView
android:id="@+id/firetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="170dp"
android:text="Android"
android:textStyle="bold"
android:textColor="@android:color/white" />
</RelativeLayout>
is there any way to scale the imageview width to scale the textview width considering that the text in the textview is dynamic 考虑到textview中的文本是动态的,有什么方法可以缩放imageview宽度来缩放textview宽度
I think this will work, but I did not try it. 我认为这会起作用,但是我没有尝试。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:orientation="vertical">
<ImageView
android:id="@+id/imf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/frame001"
/>
<TextView
android:id="@+id/firetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="170dp"
android:text="Android"
android:textStyle="bold"
android:textColor="@android:color/white" />
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/black">
<ImageView
android:id="@+id/imf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/frame001"
android:layout_alignLeft="@+id/firetext"
android:layout_alignRight="@+id/firetext" />
<TextView
android:id="@+id/firetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="170dp"
android:text="Android"
android:textStyle="bold"
android:textColor="@android:color/white" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.