2014-10-28 4 views
0

я пытаюсь реализовать перелистываемой эффект карты, так же, как приложение трут: https://play.google.com/store/apps/details?id=com.tinder&hl=en_GBViewGroup клип дети не могут быть установлены ложные

Когда я красть мою карту, вид ребенка всегда обрезается его контейнера, даже если Я установил клики и cliptopadding в false. Любая идея, почему ????

CardStack мой пользовательский макет контейнер расширяет RelativeLayout XML:

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

<com.wenchao.cardstack.CardStack 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:padding="20dp" 
    android:clipChildren="false" <!--- false --> 
    android:clipToPadding="false" 
    android:layout_weight="3" 
    /> 


<RelativeLayout 

    android:layout_weight="1" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:orientation="horizontal" 
    android:background="#FF00FF" 
    > 
    <Button 
     android:layout_centerHorizontal="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="B" 
     android:id="@+id/info" 
     /> 
    <Button 
     android:id="@+id/like" 
     android:layout_toLeftOf="@+id/info" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="A" 
     /> 
    <Button 
     android:id="@+id/dislike" 
     android:layout_toRightOf="@+id/info" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="C" 
     /> 

</RelativeLayout> 

перед красть

enter image description here

после прикосновения, днище из точки зрения ребенка обрежется :(

enter image description here

---------------- Редактировать -----------------------

Я нашел проблему что в линейном макете последний ребенок всегда отображается сверху (больший z-индекс). поэтому даже если контейнер с карточным контейнером не обрезает chirdren, его дети все еще отображаются под следующим видом ниже. Поэтому лучше переключиться на Relative layout.

Но я не очень хочу, потому что RelativeLayout не имеет приятной функции «layout_weight», чтобы указать процент высоты. Поэтому ситуация заключается в том, что я хочу легко управлять z-index (что-то невозможное для linearlayout), а также хочу сохранить функцию layout_weight (возможно, это возможно только при использовании linearlayout). Есть идеи??

ответ

0

Зачем вам нужен макет? Я предполагаю, что верхний вид заполняет все доступное пространство? Прямо сейчас вы делите экран на четверти, но если вы можете установить размер на любом из этих представлений, проблема будет решена.

<?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" 
    android:orientation="vertical"> 


    <RelativeLayout 
     android:id="@+id/button_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingBottom="@dimen/large_bottom_padding" 
     android:background="#FF00FF" 
     > 
     <Button 
      android:layout_centerHorizontal="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="B" 
      android:id="@+id/info" 
      /> 
     <Button 
      android:id="@+id/like" 
      android:layout_toLeftOf="@+id/info" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="A" 
      /> 
     <Button 
      android:id="@+id/dislike" 
      android:layout_toRightOf="@+id/info" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="C" 
      /> 

    </RelativeLayout> 

    <com.wenchao.cardstack.CardStack 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"   <!-- Not really important --> 
     android:layout_alignParentTop="true"   <!-- Because of these lines --> 
     android:layout_above="@id/button_container" <!-- Because of these lines --> 
     android:padding="20dp" 
     android:clipChildren="false" <!--- false --> 
     android:clipToPadding="false" 
     /> 

</RelativeLayout 
Смежные вопросы