开发者

android ScrollView point to the center of the view

开发者 https://www.devze.com 2023-03-09 00:23 出处:网络
In my application i\'m using a ScrollView for display an image. Sometime, when the image is bigger then the view, I want to disply the very center of the image and then scrolling the image to it\'s ed

In my application i'm using a ScrollView for display an image. Sometime, when the image is bigger then the view, I want to disply the very center of the image and then scrolling the image to it's edges. The ScrollView contains one ImageView container. How it can be done? Thanks, Eyal.

<?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:lay开发者_如何转开发out_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>


In ImageView Put

android:layout_centerInParent="true"
0

精彩评论

暂无评论...
验证码 换一张
取 消