Bob*_*ano 16 android emulation scrollview imageview
我在渲染ScrollView时遇到问题.基本上,布局是固定的页眉和页脚,中间有一个滚动视图.我们的想法是,当为内容EditText激活屏幕键盘时,如果图像的高度比中间视图长,则可以滚动图像.
在测试布局时,我发现在我的Android手机(Xperia X10 Android 1.6)上,在ImageView的顶部和底部添加了一大堆填充.
我很感激有关如何防止这种情况发生的任何建议.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Header -->
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<TextView
android:text="Share your photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"/>
<Button
android:id="@+id/btnStack"
android:text="Stacks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<!-- End Header -->
<!-- Body -->
<ScrollView
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5px"
android:background="#CCCCCC">
<ImageView
android:id="@+id/imgPreview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</ScrollView>
<!-- End Body -->
<!-- Footer -->
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/caption"
android:text="Type your caption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/caption"
android:background="#CCCCCC">
<Button
android:id="@+id/btnUpload"
android:text="Share"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="@+id/btnCancel"
android:text="Cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
<!-- End Footer -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Bob*_*ano 34
经过一些实验,我发现在我的java代码中添加以下语法解决了这个问题:
imgPreview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imgPreview.setAdjustViewBounds(true);
Run Code Online (Sandbox Code Playgroud)
ol_*_*_er 22
只需将以下属性添加到ImageView XML描述即可完成以下任务:
android:adjustViewBounds="true"
Run Code Online (Sandbox Code Playgroud)
far*_*ath 12
android:fillViewport="true"
android:fadingEdge="none"
Run Code Online (Sandbox Code Playgroud)
在scrollview中使用这些属性.
| 归档时间: |
|
| 查看次数: |
15067 次 |
| 最近记录: |