如何使用android向上滑动面板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22928573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to use android sliding up panel
提问by Opax Web
I have downloaded the umano sliding up panel from https://github.com/umano/AndroidSlidingUpPanel
我已经从https://github.com/umano/AndroidSlidingUpPanel下载了 umano 上滑面板
Imported it into the workspace and added reference to it in my project.
将其导入工作区并在我的项目中添加对它的引用。
Next I copied and pasted the following into a new layout -
接下来,我将以下内容复制并粘贴到新布局中 -
Here is the Code :
这是代码:
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Main Content"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:text="The Awesome Sliding Up Panel"
android:textSize="16sp" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
But I am getting an error unbound prefix.
但是我收到一个错误未绑定前缀。
What is wrong in my code?
我的代码有什么问题?
And How can i fix this ?
我该如何解决这个问题?
采纳答案by Raghunandan
You are missing namespace for android
您缺少 android 的命名空间
Also this
还有这个
xmlns:sothree="http://schemas.android.com/apk/res-auto"
Should be
应该
xmlns:sothree="http://schemas.android.com/apk/res/yourpackagename"
So it should be
所以应该是
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sothree="http://schemas.android.com/apk/res/yourpackagename"
considering you have custom attributes
考虑到您有自定义属性
Edit:
编辑:
Looks like you are using
看起来你正在使用
https://github.com/umano/AndroidSlidingUpPanel
https://github.com/umano/AndroidSlidingUpPanel
Its a library project and you must reference it in your andorid project. Scodnly missing android namespace as mentioned. The below should fix it
它是一个库项目,您必须在您的 andorid 项目中引用它。如上所述,非常缺少 android 命名空间。下面应该修复它
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Main Content"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:text="The Awesome Sliding Up Panel"
android:textSize="16sp" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
回答by andri_sasuke
You can use BottomSheetBehavior from android support library from google as alternative. compile 'com.android.support:design:25.0.0'
You can checkout my sample https://github.com/andrisasuke/Android-SlidingUp-Panel
您可以使用来自 google 的 android 支持库中的 BottomSheetBehavior 作为替代。compile 'com.android.support:design:25.0.0'
您可以查看我的示例https://github.com/andrisasuke/Android-SlidingUp-Panel
回答by Jishi Chen
I also implemented a SlidingUpPaneLayout, based on the SlidingPaneLayout, but the slide direction is vertical you can slide up and down for the top view, it's more simple,just two views and no more attribute need to set.see at github,https://github.com/chenjishi/SlidingUpPaneLayout
我也实现了一个SlidingUpPaneLayout,基于SlidingPaneLayout,但是滑动方向是垂直的,顶视图可以上下滑动,比较简单,只有两个视图,不需要设置更多的属性。见github,https:/ /github.com/chenjishi/SlidingUpPaneLayout
<?xml version="1.0" encoding="utf-8"?>
<com.chenjishi.slideupdemo.SlidingUpPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_up_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#FFF"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BOTTOM"
android:textSize="18sp"
android:textColor="#333"/>
</LinearLayout>
<LinearLayout
android:id="@+id/top_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#009588"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TOP"
android:textSize="18sp"
android:textColor="#333"/>
</LinearLayout>
回答by Shaikh Mohib
If you want to slide your main body along with sliding part then only then add umanoParallaxOffset attribute otherwise remove it
如果您想将主体与滑动部分一起滑动,则仅添加 umanoParallaxOffset 属性,否则将其删除
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/hidden_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:gravity="bottom"
sothree:umanoClipPanel="false"
sothree:umanoDragView="@+id/dragView"
sothree:umanoFadeColor="@android:color/transparent"
sothree:umanoOverlay="true"
sothree:umanoPanelHeight="@dimen/_69sdp"
sothree:umanoShadowHeight="@dimen/_4sdp">
//Main body content
<FrameLayout
android:id="@+id/main_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Body...........
</FrameLayout>
//Sliding content
<FrameLayout
android:id="@+id/main_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Body...........
</FrameLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
Don't forget it! sothree:umanoOverlay="true"
不要忘记它!sothree:umanoOverlay =“真”
<style name="AppTheme">
<item name="android:windowActionBarOverlay">true</item>
</style>
回答by RQube
you are getting unbound prefix error means you are done with referencing the library, you just need to modify xmlns attributes and make the slidingUpPanelLayout the root and you are done. dont't forgot to change "com.example.slidinguppanel" with your package name. Hope it will fix your problem.
您收到未绑定前缀错误意味着您已经完成了对库的引用,您只需要修改 xmlns 属性并使 slideUpPanelLayout 成为根就完成了。不要忘记使用您的包名更改“com.example.slidinguppanel”。希望它能解决你的问题。
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sothree="http://schemas.android.com/apk/res/com.example.slidinguppanel"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Main Content"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:text="The Awesome Sliding Up Panel"
android:textSize="16sp" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>