如何Onclick Image带来正面文字?
我有一个布局,我使用imageView1.bringToFront();在按钮onclick事件但不工作!
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<ImageView
android:id="@+id/imageView1"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="247dp"
android:layout_gravity="center"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Frame Demo"
android:textAppearance="?android:attr/textAppearanceLarge" />
和MainActivity
btn = (Button)findViewById(R.id.btn);
imageView1 = (ImageView)findViewById(R.id.imageView1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
imageView1.bringToFront();
}
});
你能帮帮我吗?谢谢!
答案 0 :(得分:0)
setVisibility(View.GONE)
TextView
答案 1 :(得分:0)
这样做:boolean isclicked = true;
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(isClicked){
firstClick();
isClicked=false
}else{
secondClick();
isClicked=true;
}
}
firstClick(){
((View)Imageview.getParent()).requestLayout();
Imageview.bringChildToFront(this);}
});
}
secondClick(){
///Do Your code
}
让我知道它是否有效