【问题标题】:android ScrollView point to the center of the viewandroid ScrollView 指向视图的中心
【发布时间】:2011-09-04 17:22:44
【问题描述】:

在我的应用程序中,我使用 ScrollView 来显示图像。 有时,当图像大于视图时,我想显示图像的中心,然后将图像滚动到边缘。 ScrollView 包含一个 ImageView 容器。 怎么做? 谢谢, 艾尔。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

    <RelativeLayout android:id="@+id/relativeLayout1" 
        android:layout_height="match_parent" 
        android:layout_width="match_parent">

        <ScrollView android:id="@+id/scrollView1" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content"
            android:layout_weight="1.0">

            <ImageView android:id="@+id/imgImageView" 
                android:layout_height="wrap_content"  
                android:layout_alignParentLeft="true" 
                android:layout_width="wrap_content" 
                android:layout_gravity="center"/>

        </ScrollView>

        <TextView android:layout_height="wrap_content" 
            android:id="@+id/addrTextView" 
            android:layout_alignParentBottom="true" 
            android:layout_width="match_parent" 
            android:gravity="center"
            android:textSize="12px"
            android:layout_weight="0.0"/>
    </RelativeLayout>

</LinearLayout>

【问题讨论】:

    标签: android imageview scrollview center


    【解决方案1】:

    在ImageView中放

    android:layout_centerInParent="true"
    

    【讨论】:

      猜你喜欢
      • 2021-01-09
      • 2017-12-08
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多