【发布时间】:2012-09-10 09:53:32
【问题描述】:
我有布局,它包含两部分:标题和正文。标题包含 TextView 和图像。标题高度可以通过编程方式更改。并且标题的图像和文本必须分别缩放。图像缩放可以,但文本不想缩放。在 Android 上是否可行?如何做到这一点?
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="UseCompoundDrawables" >
<TextView
android:id="@+id/title_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/app_name" />
<ImageView
android:id="@+id/edit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/edit"
android:src="@drawable/widget_edit" />
</LinearLayout>
<TextView
android:id="@+id/content_text"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
【问题讨论】:
-
不,使用 xml 是不可行的。你指的是iphone的scaleToFit