[英]Android Resize imageView to fullscreen with orientation
我有一個包含imageview的xml,我希望單擊它時,考慮到圖像的方向,將其調整為LinearLayout的大小。 然后單擊,默認情況下替換圖像。
我的Xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/grey"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/goToDayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_btn_find_prev"
android:contentDescription="@string/imgbPrev" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.40"
android:orientation="vertical" >
<TextView
android:id="@+id/textNameService"
style="@style/txtvServiceName"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="@string/largetext"
android:textSize="20sp" />
</LinearLayout>
<ImageButton
android:id="@+id/goToNextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_btn_find_next"
android:contentDescription="@string/imgbNext"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/sentImageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@drawable/frame_shadow"
android:contentDescription="@string/description"
android:scaleType="fitXY"
android:src="@drawable/montreal" />
<TextView
android:id="@+id/textDescription"
style="@style/txtvServiceDescription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:maxLines="20"
android:textSize="20sp" />
<LinearLayout
android:id="@+id/pageIndicatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal"
android:paddingBottom="2dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingTop="2dp" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
你能幫我嗎?
我想您需要在單擊ImageView時對其進行縮放,並在再次單擊時進行縮小。 Android給出了一個例子 。這可能對您有所幫助。
更新時間 :
這是DevBytes中類似效果的一個很好的例子。 它在ActivityOptions中使用新的API,可以直接從JellyBean獲得,也可以通過support-v4庫進行訪問
從該示例中摘錄的代碼在這里:
Intent i = new Intent(HomeActivity.this, DetailActivity.class);
i.putExtra(DetailActivity.EXTRA_COLOUR, colour);
Bundle b = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
bitmap.eraseColor(colour);
b = ActivityOptions.makeThumbnailScaleUpAnimation(view, bitmap, 0, 0).toBundle();
}
startActivity(i, b);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.