能见度安卓布局GONE [英] android layout with visibility GONE
本文介绍了能见度安卓布局GONE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
四个视图使用相同的XML。我想说明的
只能查看1线性布局。
我把安卓知名度=水涨船高
XML格式。然后我做了以下的视图1
-
的LinearLayout layone =(的LinearLayout)view.findViewById(R.id.layone);
layone.setVisibility(View.VISIBLE);
但是,这并不设置能见度可见。
是不是有可能显示视图一旦其宣称在XML GONE
?
我不希望通过只是在做交谈逻辑,
layone.setVisibility(View.GONE);
在每三个次除外视图1
的意见或建议?
更新:
我的XML -
<的TextView
机器人:ID =@ + ID / layone
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=previous页
机器人:文字颜色=#000000
机器人:TEXTSIZE =16DP
机器人:以下属性来=10dp
机器人:layout_marginTop =10dp
机器人:能见度=水涨船高/>
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =50dp
机器人:方向=横向
机器人:填充=10dp
机器人:重力=center_vertical
机器人:layout_marginLeft =10dp
机器人:layout_marginRight =10dp
机器人:标签=prevEntries
机器人:ID =@ + ID / laytwo
机器人:layout_marginTop =10dp
机器人:背景=@布局/ roundedtext
机器人:能见度=水涨船高>
<的TextView
机器人:ID =@ + ID / laythree
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:文本=previous页
机器人:文字颜色=#000000
机器人:TEXTSIZE =18dp
机器人:重力=中心
机器人:TEXTSTYLE =黑体/>
< / LinearLayout中>
解决方案
有它这样的完成:
查看= inflater.inflate(R.layout.entry_detail,集装箱,假);
TextView的TP1 =(TextView中)view.findViewById(R.id.tp1);
的LinearLayout layone =(的LinearLayout)view.findViewById(R.id.layone);
tp1.setVisibility(View.VISIBLE);
layone.setVisibility(View.VISIBLE);
Four views are using same xml. I want to show a linear layout for view 1
only.
I put android:visibility="gone"
in xml. And then I am doing the following for view 1
-
LinearLayout layone= (LinearLayout) view.findViewById(R.id.layone);
layone.setVisibility(View.VISIBLE);
But that doesn't set the visibility to visible.
Isn't it possible to show the view once its declared GONE
in xml ?
I don't want to converse the logic by just doing,
layone.setVisibility(View.GONE);
in each of the three views except view 1.
Ideas or comments?
UPDATE:
My xml -
<TextView
android:id="@+id/layone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previous Page"
android:textColor="#000000"
android:textSize="16dp"
android:paddingLeft="10dp"
android:layout_marginTop="10dp"
android:visibility="gone" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:padding="10dp"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:tag="PrevEntries"
android:id="@+id/laytwo"
android:layout_marginTop="10dp"
android:background="@layout/roundedtext"
android:visibility="gone" >
<TextView
android:id="@+id/laythree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Previous Page"
android:textColor="#000000"
android:textSize="18dp"
android:gravity="center"
android:textStyle="bold" />
</LinearLayout>
解决方案
Done by having it like that:
view = inflater.inflate(R.layout.entry_detail, container, false);
TextView tp1= (TextView) view.findViewById(R.id.tp1);
LinearLayout layone= (LinearLayout) view.findViewById(R.id.layone);
tp1.setVisibility(View.VISIBLE);
layone.setVisibility(View.VISIBLE);
这篇关于能见度安卓布局GONE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文