我正在尝试实现一个SlidingDrawer
占据全屏宽度的内容,但其高度由其内容动态确定:换句话说,fill_parent
宽度和wrap_content
高度的标准布局行为.这正是我在布局XML中指定它的方式(见下文),但滑动抽屉始终打开到全屏高度.我的内容高度各不相同,但通常它只有屏幕高度的一半左右,所以我最终会在它下面留下一个很大的空隙.我想要的是内容整齐地放在屏幕的底部.
我已经尝试了所有我能想到的东西来解决它但到目前为止还没有任何工作.如果我将SlidingDrawer
's layout_height
设置为特定值(例如160dip
)它可以工作,但这不是我需要的:它必须是动态的.当然,我已经确保所有子元素的高度也都设置wrap_content
了.
关于SlidingDrawer的文档在这方面有点模糊,我无法找到任何能够完成我所做的事情的例子.如果有人能看到我出错的地方,我真的很感谢你的帮助!
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ViewFlipper
android:id="@+id/ImageFlipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imageView0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop" />
</ViewFlipper>
<SlidingDrawer
android:id="@+id/infoDrawer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:handle="@+id/infoDrawerHandle"
android:content="@+id/infoDrawerContent"
android:allowSingleTap="false"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<!-- Sliding drawer handle -->
<ImageView
android:id="@id/infoDrawerHandle"
android:src="@drawable/info_handle_closed"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- Sliding drawer content: a scroller containing a group of text views
laid out …
Run Code Online (Sandbox Code Playgroud) 我想实现像FB或G + app这样的滑动菜单,我从FB菜单演示和https://github.com/jfeinstein10/SlidingMenu中找到了一些示例代码
这些都是好的开始,但我需要额外的东西.就像这里一样,它仅适用于单击菜单按钮,但我也希望通过手势移动它.我希望有一个中心视图的行为,并且在向右移动该中心时,将出现一个视图,并且在向左移动时,菜单将出现.假设有三个视图A,B,C,当我向左滑动C然后出现A时,当我向右滑动C然后出现B. C位于A和B的中间.
1.中间视图向右移动
走向正确
2.将中间视图移向左侧
向左移动
现在我的问题是:开发这样的观点的最佳实践是什么.我从某人那里听说我应该使用片段和View寻呼机.那么我该如何开发呢?是否有人做过任何样本实施?任何帮助和建议表示赞赏.
有关参考,请参阅此应用程序使用此类型的滑动黑白视图Skout应用程序
android slidingdrawer android-layout android-fragments android-viewpager
我在一个活动中有一个滑动抽屉菜单,它有一个动作栏,上面有一些标签.
我想让滑动抽屉滑过标签,而不是它们下方.
这就是它现在的样子......
关于如何做到这一点的任何想法?
注意:我知道我可能在这里打破了一些约定和UI模式,如果它根本不起作用,我会看一些替代方案.但我想先让它工作.
编辑:请参阅下面的Google Play音乐应用屏幕截图,该应用完全符合我的需求.请参阅下面@ CommonsWare的答案,他确实同意我可能违反惯例.但是,鉴于播放音乐应用程序,它可能也不是那么罕见.
android slidingdrawer android-ui android-actionbar android-tabs
我正在尝试创建和改进现有的SlidingDrawers项目,这些项目可以适用于屏幕的所有四个边{LEFT,RIGHT,TOP,BOTTOM}.有一些库,但它们都有局限性,复杂性和错误.其中一个比较常见的是umano的AndroidSlidingUpPanel,但是,我不喜欢这个库,因为你只需要包含两个子布局,并且还需要注意主要内容的具体安排.其他库类似,或更复杂,或有bug.
我接近完成我的SlidingDrawers版本,我专注于BOTTOM引力.我需要一些帮助.单击抽屉将打开并关闭它.您也可以用手指滑动抽屉.但是,如果你扔掉抽屉,整个视图将会移动到比它应该更低或更低的位置.
我该如何解决这个问题?据我所知,我的数学是正确的.我传给动画师的翻译价值应该是正确的.以下是我完成的工作.请查看此项目https://github.com/drxeno02/CustomDrawerLayout.git.先感谢您.
对于那些想要查看有问题的代码看起来的片段的人来说,这就是我目前正在做的手势.
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mActivePointerId = MotionEventCompat.getPointerId(event, 0);
switch (mStickTo) {
case GRAVITY_BOTTOM:
case GRAVITY_TOP:
mInitialCoordinate = event.getY();
break;
case GRAVITY_LEFT:
case GRAVITY_RIGHT:
mInitialCoordinate = event.getX();
break;
}
break;
case MotionEvent.ACTION_MOVE:
float coordinate = 0;
switch (mStickTo) {
case GRAVITY_BOTTOM:
case GRAVITY_TOP:
coordinate = event.getY();
break;
case GRAVITY_LEFT:
case GRAVITY_RIGHT:
coordinate = event.getX();
break;
}
final int diff = (int) Math.abs(coordinate - mInitialCoordinate);
// confirm that difference …
Run Code Online (Sandbox Code Playgroud) 我刚刚注意到,自从API 17 SlidingDrawer以来,它已被弃用.
对它的评论说:
此类在API级别17中已弃用. 此类不再受支持.如果您必须在应用程序中使用它,建议您将自己的实现基于Android开源项目的源代码.
这是否意味着我应该将代码导入到我的项目中,以确保将来会支持它?
是否有一些开源项目将slidingDrawer扩展到那里?
我slidingDrawer
在我的应用程序中使用a ,在纵向模式下将其处理程序放在底部.当用户切换到横向模式(宽屏)时,我希望处理程序位于左侧.当我将方向从垂直方向更改为水平方向时,处理程序位于右侧.
我已经像这样定义了我的布局XML:
<SlidingDrawer
android:id="@+id/l_drawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:handle="@+id/l_handle"
android:content="@+id/l_content"
android:orientation="horizontal"
android:layout_gravity="left"
>
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何让它从左向右滑动?
这就是场景:我有一个按钮B,一个拉出的抽屉,覆盖整个屏幕.当我拉出屏幕并触摸B曾经可见的屏幕时,其动作仍然执行.
我怎么能绕过这个?
我发现这个帖子描述了同样的问题,但是没有接受任何答案,而且给出的答案我没有设法工作.
更新:我有一个名为Report.java的文件,其中包含相应的report.xml文件,如下所示.
<SlidingDrawer
android:id="@+id/drawer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:handle="@+id/reportSlideButton"
android:content="@+id/reportContent"
android:orientation="horizontal">
<LinearLayout
android:id="@id/reportContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:padding="10dp"
android:background="@color/bg_color">
<TextView android:id="@+id/garbageTypeTextView"
android:layout_height="wrap_content"
android:textColor="@color/text"
android:layout_width="fill_parent"
android:text="@string/garbageTypeString"
android:textStyle="bold"/>
<Spinner android:id="@+id/garbageTypeSpinner"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<TextView android:id="@+id/textViewForDateTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dateString"
android:textColor="@color/text"
android:textStyle="bold" />
<TextView android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text" />
<TextView android:id="@+id/textViewForAddressTitle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/addressString"
android:textColor="@color/text"
android:textStyle="bold" />
<TextView android:id="@+id/addressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text" />
<TextView android:id="@+id/textViewForPositionTitle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/positionString"
android:textColor="@color/text"
android:textStyle="bold" />
<TextView android:id="@+id/positionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text" />
<TextView android:id="@+id/textViewForCommentTitle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/commentString"
android:textColor="@color/text" …
Run Code Online (Sandbox Code Playgroud) 嘿,我需要从屏幕底部的一些滑动菜单.我看到SlidingDrawer已被弃用.
那么什么是SlidingDrawer的替代品,我可以用它从底部向上滑动.
我知道有NavigationDrawer,但我认为这只能用于从左到右滑动和反向滑动,或者?
我有一个从屏幕底部弹出的SlidingDrawer,填充屏幕大约80%.即使SlidingDrawer视图处于焦点,仍然可以单击SlidingDrawer后面的视图中的项目,按钮和其他元素.当SlidingDrawer处于活动/上拉/焦点时,我想要禁用其后面的整个视图,以便它无法接收点击和触摸.是否有一种禁用整个视图的好方法?我已经尝试过setEnable(false)和setClickable(false)但它们都不起作用.
救命?
我正在开发一个包含许多活动的应用程序,我创建了自己的菜单(我不想使用内置的菜单按钮)和滑动抽屉,因为滑动抽屉位于屏幕的底部并包含我的菜单按钮
我需要的是使滑动抽屉出现在我的所有活动中
我试图创建一个活动,并将其内容视图设置为包含抽屉的xml文件,然后在所有其他活动中扩展该活动,但此解决方案不起作用
有什么建议吗?
android ×10
slidingdrawer ×10
layout ×2
android-tabs ×1
android-ui ×1
clickable ×1
deprecated ×1
drawerlayout ×1
gesture ×1
menu ×1
slidingmenu ×1
view ×1