如何显示在安卓/隐藏分组的看法?看法

由网友(少年狂)分享简介:我想创建如提到照片的活动...只要我preSS最大化按钮,我希望它成为全屏的活动,第1部分变得最小化,而当我再次pressed还原按钮,我想成为第一个状态是指能够看到第1部分和第2部分... i want to create an activity such as mentioned in photo...as...

我想创建如提到照片的活动... 只要我preSS最大化按钮,我希望它成为全屏的活动,第1部分变得最小化,而当我再次pressed还原按钮,我想成为第一个状态是指能够看到第1部分和第2部分...

i want to create an activity such as mentioned in photo... as soon as i press maximize button i want it to become full screen for activity and part 1 become minimize, and again when i pressed Restore button i want to become in a first state means be able to see part 1 and part 2 ...

我想,如果我们把两个布局是可能的吗?是不是? 请reffer我的资源可以帮助我这个,还是让我的code来实现这个问题

i think if we put two layout it is possible? isnt it? please reffer me to a resource can help me about this, or show me the code to achieve this problem

在此先感谢

推荐答案

第一部分和两个应该是在自己的布局。之后,玩每个布局的 visilibity 属性。具体要隐藏任何视图没有它仍然占据它的空间,使用值消失的可见性属性。

Part one and two should be in their own layout. After, play with the visilibity property of each layout. Specifically to hide any view without it continues to occupy its space, use the value gone for the visibility property.

好了,在这里我走了。下面你有如何隐藏一个完整的例子/显示分组的看法。

Ok, here I go. Below you have a complete example of how to hide/show grouped views.

的main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/viewsContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="5dp" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TextBox One" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:text="TextBox Two" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:text="TextBox Three" />
    </LinearLayout>

    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Hide" />

</RelativeLayout>

活动

public class MyActivity extends Activity implements OnClickListener {

    private boolean viewGroupIsVisible = true;  

    private View mViewGroup;
    private Button mButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mViewGroup = findViewById(R.id.viewsContainer);

        mButton = findViewById(R.id.button);
        mButton.setOnClickListener(this);
    }


    @Override
    public void onClick(View button) {

    if (viewGroupIsVisible) {
        mViewGroup.setVisibility(View.GONE);
        mButton.setText("Show");
    } else {
        mViewGroup.setVisibility(View.VISIBLE);
        mButton.setText("Hide");
    }

    viewGroupIsVisible = !viewGroupIsVisible;
}

我希望这有助于;)

I hope this helps ;)

阅读全文

相关推荐

最新文章