mof*_*tje 1 android android-layout android-adapter android-relativelayout
我有一个RelativeLayout:
<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" android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
tools:context="com.pinder.moffel.pinder.DeleteActivity"
android:id="@+id/deleteBackground">
<com.andtinder.view.CardContainer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tinderview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我正在使用AndTinder库:https://github.com/kikoso/Swipeable-Cards
我已经知道如何添加新卡,但问题是,因为正在添加新布局,新卡会显示在其他视图之上.
我想在活动加载时添加3张卡片,然后在刷卡时在所有其他卡片后面添加一张新卡片.
如何在RelativeLayout中的所有其他视图后面展开新视图?
一些额外的代码:
JAVA代码
SimpleCardStackAdapter adapter = null;
CardContainer mCardContainer = (CardContainer) findViewById(R.id.tinderview);
adapter = new SimpleCardStackAdapter(this);
CardModel newCard = new CardModel(null, null, image); //image is retrieved before
adapter.add(newCard); //the new card will now be on top of the others, i want it to be behind them
mCardContainer.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
正在添加的XML视图
<RelativeLayout
android:id="@+id/global_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignWithParentIfMissing="true"
android:layout_centerHorizontal="true"
android:scaleType="fitCenter"
tools:src="@drawable/picture1"/>
<View
android:id="@+id/divider_bottom"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="@id/image"
android:background="@color/card_outline" />
<View
android:layout_width="fill_parent"
android:layout_height="10dp"
android:layout_alignBottom="@+id/layoutButton"
android:layout_below="@+id/divider_bottom"
android:background="@color/card_bg"
/>
<!-- An invisible view aligned to the center of the parent. Allows other
views to be arranged on either side -->
<LinearLayout
android:id="@+id/layoutButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/divider_bottom"
android:gravity="center"
>
<ImageButton
android:id="@+id/image_1"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/denied"
android:padding="10dp"
android:layout_marginRight="80dp"/>
<ImageButton
android:id="@+id/image_2"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/heart"
android:padding="10dp"
android:layout_alignParentRight="true" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在另一个问题(如何将视图放在另一个后面)中,答案表明不可能在其他人之后添加视图,但我认为必须有一种方法来实现这一目标.
您可以使用ViewAnimator
其文档可在http://developer.android.com/reference/android/widget/ViewAnimator.html上找到
在这里,您需要在View Animator中创建两个子布局.您可以定义自己的子布局.并且可以使用next和previous方法来处理事件.我之前在我的一个项目中使用过它.
| 归档时间: |
|
| 查看次数: |
1064 次 |
| 最近记录: |