Board logo

標題: Android App - imageview 顯示與隱藏 [打印本頁]

作者: admin    時間: 2013-6-19 22:35     標題: Android App - imageview 顯示與隱藏

方法一, 在XML檔內加入

顯示
<ImageView
android:id="@+id/custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:src="@drawable/custom1"
android:visibility="visible"/>


隱藏
<ImageView
android:id="@+id/custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:src="@drawable/custom1"
android:visibility="invisible"/>


隱藏
<ImageView
android:id="@+id/custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:src="@drawable/custom1"
android:visibility="gone"/>


方法二, 在JAVA 檔內加入


ImageView imgView =(ImageView)findViewById(R.id.custom);


imgView .setVisibility(View.VISIBLE);
imgView .setVisibility(View.INVISIBLE);
imgView .setVisibility(View.GONE);





歡迎光臨 How2Do (http://forum.how2do.com.hk/) Powered by Discuz! 7.2