2013-06-17 3 views
-1

다음 결과에 도달해야합니다. 내 RelativeLayout 오버레이는 처음에 https://dl.dropboxusercontent.com/u/4277073/view1.png처럼 보입니다. 따라서 레이아웃의 20 % 만보아야합니다. Button을 누르면화면에서 레이아웃을 배치하는 방법

Animation 그래서 그 레이아웃이 상승하고 다음 https://dl.dropboxusercontent.com/u/4277073/view2.png

오버레이 레이아웃이 부모 RelativeLayout에 배치하고 거기에 ImageButtons의 수를 가지고 있습니다 보인다 적용됩니다.

rlOverlay = (RelativeLayout) v.findViewById(R.id.overlay); 
ViewTreeObserver vto = rlOverlay.getViewTreeObserver(); 
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 
@Override 
     public void onGlobalLayout() { 
      WindowManager wm = (WindowManager) MainActivity.appContext.getSystemService(Context.WINDOW_SERVICE); 
      Display display = wm.getDefaultDisplay(); 
      int height = display.getHeight(); // deprecated, my app is for API 2.1+ 
      rlOverlay.layout(0, (int)(height*0.8), rlOverlay.getMeasuredWidth(), rlOverlay.getMeasuredHeight()); 
     } 
    }); 

불행하게도 나던 위의 코드 레이아웃의 위치에 영향을 다음과 같이

<RelativeLayout 
    android:id="@+id/overlay" 
    android:layout_width="match_parent" 
    android:layout_below="@+id/actionbar" 
    android:layout_height="wrap_content" 
    android:background="@drawable/backgroundfeedme" 
    android:clickable="true" 
    > 
-----number of img buttons here -- 
</RelativeLayout> 

나는 초기 위치를 설정하려고했다. 레이아웃을 쥐어 짜기 때문에 여백도 사용하지 않습니다.

그럼 레이아웃을 배치하여 20 % 만 처음에 볼 수 있도록 배치하는 방법은 무엇입니까?

감사합니다.

+0

당신이 애니메이션을 사용하여 생각 해 봤나 :

여기에 코드입니까? 그것의 최종 위치에 'RelativeLayout'을 배치하고 생성시 그것을 아래로 움직입니다. 버튼을 누르면 움직입니다. –

+0

@NeilTownsend 실제로 나는 그것을 생각하지 않았다! 좋은 소리, 트릭을 만들어야합니다. 나는 지금 일하도록 노력하고있다. 시간이 걸린다. 나는 애니메이션에 아주 익숙하다. 감사합니다. – user2224342

답변

0

나는 동일한 requirment가 있었다. 내가 한 일은 상대적인 레이아웃 두 가지입니다. 첫 번째 레이아웃에서 버튼을 누른 다음 나머지 뷰와 함께 두 번째 레이아웃과 Visiblity = 사라졌습니다.

코드에서 : 버튼을 클릭하면 seided 레이아웃으로 표시 visiblity = Visible 및 animate합니다.

<RelativeLayout 
    android:id="@+id/llShopping" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/bar_green" > 

    <Button 
     android:id="@+id/btnShoppingListAddItem" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/bar_green" 
     android:gravity="center" 
     android:paddingLeft="5dp" 
     android:text="Add Item" 
     android:textColor="@android:color/white" 
     android:textSize="20sp" 
     android:textStyle="bold" /> 

    <RelativeLayout 
     android:id="@+id/relAddItemChild" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/btnShoppingListAddItem" 
     android:layout_marginBottom="10dp" 
     android:visibility="gone" > 

     <View 
      android:id="@+id/gl" 
      android:layout_width="200dp" 
      android:layout_height="1dp" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="1dp" 
      android:background="@android:color/white" /> 

     <EditText 
      android:id="@+id/edtItemName" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/gl" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="5dp" 
      android:hint="Item Name..." /> 

     <Button 
      android:id="@+id/btnSpinner" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edtItemName" 
      android:layout_centerHorizontal="true" 
      android:text="Please pick store" /> 

     <Button 
      android:id="@+id/btnAddToList" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/btnSpinner" 
      android:layout_centerHorizontal="true" 
      android:layout_marginBottom="20dp" 
      android:layout_marginTop="15dp" 
      android:background="@drawable/btn_blue" 
      android:padding="5dp" 
      android:text="Add To List" 
      android:textColor="@android:color/white" 
      android:textSize="20sp" /> 
    </RelativeLayout> 
</RelativeLayout> 
+0

답변 해 주셔서 감사합니다. 나는 당신의 제안을 좋아합니다. 그러나 나는 내 단추에 대한 이미지 모양을 고정시킬 수 있다고 생각하지 않는다. 파란색 오버레이에 배경 이미지를 사용하고 있습니다. 그러나 화면 해상도에 따라 다르게 펼쳐 지므로 각도가 다를 수 있습니다. 그게 내가 내 단추를 위해 내 이미지를자를 수없는 것 같아. 다른 방법이 있습니까? – user2224342

관련 문제