1

我在布局中有两个视图。单击视图 1 中的按钮时,第二个视图必须可见,并且必须将视图 1 拖入(尽管不完全)。如果不清楚,我很抱歉。为了简化我的工作附上一些图片。在此处输入图像描述

当我点击按钮 2 时;视图 1 变为可见(白色视图)并且应该占据大约 85% 的屏幕,并且只有一部分蓝色球应该在屏幕上可见。到目前为止我所做的是我已将视图 1 的权重设为 0.2 和将 2 视为 0.80。并且查看 1 已消失。在按钮单击(按钮 2)上,我已将视图 1 设为可见。这工作正常,但我希望只有部分蓝色球在屏幕上可见,但是蓝色球出现挤压而不是只有球的一部分可见。有人可以告诉我我在这方面做错了什么吗?或者有其他方法可以做到这一点吗?提前谢谢如果有人可以帮助我!!!

我的xml文件如下:

<LinearLayout
        android:id="@+id/rootlayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="1"
    >

    <LinearLayout
                android:id="@+id/bbb"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.9"

               >
          <include
                android:id="@+id/background_template_top"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                layout="@layout/menuitems"
           />


    </LinearLayout>


<RelativeLayout
    android:id="@+id/parentlayout"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:orientation="vertical"
     android:layout_weight="0.1"
   >

   <include
        android:id="@+id/background_template_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        layout="@layout/template_top"
        android:layout_alignParentTop="true"
        >

     </include>

   <RelativeLayout
       android:id="@+id/parent_middle_botom"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:layout_below="@+id/background_template_top"
       >


<RelativeLayout
    android:id="@+id/middle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/black_strip_med"
    android:layout_below="@+id/background_template_top"
    >

    <LinearLayout
        android:id="@+id/text_data"
        android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true"
        android:layout_toRightOf="@+id/imageView1"
        android:layout_marginLeft="30dp"
        android:orientation="vertical"
        >

         <TextView
        android:id="@+id/welcome"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome,"
        android:textColor="#FFFFFFFF"
        android:textSize="20sp"
          android:singleLine="true"
        >

    </TextView>

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Joyson"
        android:layout_below="@+id/welcome"
          android:textColor="#FFFFFFFF"
        android:textSize="24sp"
        android:singleLine="true"
        >
    </TextView>

        </LinearLayout>



    </RelativeLayout>

     <include
        android:id="@+id/background_template_bottom"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        layout="@layout/template_bottom"
       android:layout_below="@+id/middle"
       >
      </include>

     <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true"
        android:background="@drawable/round_sm_device"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="10dp"

        />

          <RelativeLayout
         android:id="@+id/details"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_below="@+id/imageView1"
         android:layout_marginLeft="28dp"
         >
         <ImageView
         android:id="@+id/imageView2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"

         android:src="@drawable/btn_on_small" />

         <TextView
         android:id="@+id/currentbatch"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="Current Batch :"
         android:layout_toRightOf="@+id/imageView2"
         android:textSize="20dp"
         android:textStyle="bold"
           android:singleLine="true"
         />

         <ImageView
         android:id="@+id/dummy"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@drawable/btn_on_small" 
        android:layout_below="@+id/imageView2"
        android:visibility="invisible"
         />
         <TextView
             android:id="@+id/count"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_below="@+id/currentbatch"
             android:text="0"
            android:layout_toRightOf="@+id/dummy"
            android:layout_marginLeft="4dp"
            android:layout_marginTop="4dp"
             >
             </TextView>

    <TextView
             android:id="@+id/Transaction"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="Transactions |"
            android:layout_toRightOf="@+id/count"
            android:layout_marginLeft="4dp"
            android:layout_below="@+id/currentbatch"
             android:layout_marginTop="4dp"
             android:textSize="15sp"
               android:singleLine="true"
             >
             </TextView>

         <TextView
             android:id="@+id/value"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="$ 0.00"
            android:layout_toRightOf="@+id/Transaction"
            android:layout_marginLeft="4dp"
            android:layout_below="@+id/currentbatch"
             android:layout_marginTop="4dp"
             android:textSize="15sp"
               android:singleLine="true"
             >
             </TextView>


       </RelativeLayout>

     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="true"
         android:background="@drawable/welcome_bg_small"
         >
      </RelativeLayout>

     </RelativeLayout>
    </RelativeLayout>


</LinearLayout>
</RelativeLayout>

这是我包含的文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

     <ScrollView 
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_centerHorizontal="true"
         android:scrollbars="none"
         android:layout_marginTop="14dp">

<RelativeLayout
    android:id="@+id/parentlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   >

   <LinearLayout
       android:id="@+id/creditcard_functions"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:background="@drawable/med_black_strip"
       android:orientation="vertical"
       >
       <TextView
           android:id="@+id/reporting"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Reporting"
           android:textColor="#FFFFFFFF"
           android:paddingLeft="8dp"
           android:textSize="20dp"
           android:textStyle="bold"
           >
         </TextView>


       <TextView
            android:id="@+id/functions"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Functions"
           android:textColor="#FFFFFFFF"
           android:paddingLeft="8dp"
           android:textSize="20dp"
             android:textStyle="bold"
          >
        </TextView>
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/sale"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/creditcard_functions"
        android:background="@drawable/med_black_strip"

        >
        <ImageView
            android:id="@+id/sale_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/balance_inquiry_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/saletext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Sale"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >

            </TextView>


        </RelativeLayout>


    <RelativeLayout
        android:id="@+id/authorizeonly"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/sale"
        android:background="@drawable/med_black_strip"

        >
        <ImageView
            android:id="@+id/authorize_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/balance_inquiry_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/authorize_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
              android:text="Sale"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>


     <RelativeLayout
        android:id="@+id/Ticketonly"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/authorizeonly"
        android:background="@drawable/med_black_strip"

        >
        <ImageView
            android:id="@+id/ticketonly_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
             android:background="@drawable/balance_inquiry_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/tickettext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:text="Sale"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>

     <RelativeLayout
         android:id="@+id/giftcardfunctions"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
        android:layout_below="@+id/Ticketonly"
        android:background="@drawable/med_black_strip"

         >
         <TextView
             android:id="@+id/giftcardfunctionstext"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text=" Functions"
           android:textColor="#FFFFFFFF"
           android:paddingLeft="8dp"
           android:textSize="20dp"
           android:textStyle="bold"
           android:layout_centerVertical="true"
             >
             </TextView>

         </RelativeLayout>


         <RelativeLayout
        android:id="@+id/Redeem"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/giftcardfunctions"
        android:background="@drawable/med_black_strip"

        >
        <ImageView
            android:id="@+id/redeeem_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/balance_inquiry_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/redeemtext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:text="Sale"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>



         <RelativeLayout
        android:id="@+id/Activate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Redeem"
        android:background="@drawable/med_black_strip"
        >
        <ImageView
            android:id="@+id/activate_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/balance_inquiry_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/activatetext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Sale"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>


          <RelativeLayout
        android:id="@+id/Deactivate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Activate"
        android:background="@drawable/med_black_strip"
        >
        <ImageView
            android:id="@+id/deactivate_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
             android:background="@drawable/balance_inquiry_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/deactivatetext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
          android:text="Sale"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>


            <RelativeLayout
        android:id="@+id/Addvalue"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Deactivate"
        android:background="@drawable/med_black_strip"
        >
        <ImageView
            android:id="@+id/addvalue_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/add_value"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/addvaluetext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Add Value"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>



         <RelativeLayout
        android:id="@+id/BalanceInquiry"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Addvalue"
        android:background="@drawable/med_black_strip"
        >
        <ImageView
            android:id="@+id/balanceinquiry_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/balance_inquiry_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/balanceinquirytext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Balance Inquiry"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>

         <RelativeLayout
        android:id="@+id/Transfer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/BalanceInquiry"
        android:background="@drawable/med_black_strip"
        >
        <ImageView
            android:id="@+id/transfer_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/transfer_icon"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            >
        </ImageView>

        <TextView
            android:id="@+id/transfertext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Transfer"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFFFF"
            android:textSize="25sp"
            android:textStyle="bold"
            >
         </TextView>
        </RelativeLayout>

    </RelativeLayout>
    </ScrollView>

</RelativeLayout>
4

1 回答 1

0

您应该能够使用其中一种滑动菜单模式实现来获得这样的交互。Jeremy Feinstein 实现了最常用的方法之一,您可以在 github 上获取它:https ://github.com/jfeinstein10/SlidingMenu

它使用起来非常简单,您可以在 xml 或代码中使用它。查看github 上的readme页面以获取有关设置的更多信息。

您甚至可以在这里找到一个示例 Eclipse 项目。它将帮助您弄脏代码。

于 2013-03-01T10:55:38.183 回答