我已从https://github.com/umano/AndroidSlidingUpPanel
下载了umano向上滑动面板将其导入工作区并在我的项目中添加对它的引用。
接下来,我将以下内容复制并粘贴到新版面中 -
以下是代码:
<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>
但我收到错误的未绑定前缀。
我的代码有什么问题?
我该如何解决这个问题?
答案 0 :(得分:7)
你缺少android的名称空间
也是这个
xmlns:sothree="http://schemas.android.com/apk/res-auto"
应该是
xmlns:sothree="http://schemas.android.com/apk/res/yourpackagename"
所以它应该是
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sothree="http://schemas.android.com/apk/res/yourpackagename"
考虑到你有自定义属性
编辑:
看起来你正在使用
https://github.com/umano/AndroidSlidingUpPanel
它是一个库项目,您必须在您的andorid项目中引用它。如上所述,Scodnly缺少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>
答案 1 :(得分:3)
您可以使用谷歌Android支持库中的BottomSheetBehavior作为替代方案。 compile 'com.android.support:design:25.0.0'
您可以查看我的示例https://github.com/andrisasuke/Android-SlidingUp-Panel
答案 2 :(得分:2)
我还实现了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>
答案 3 :(得分:1)
如果要与滑动部件一起滑动主体,则仅添加 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>
别忘了它! sothree:umanoOverlay =“ true”
<style name="AppTheme">
<item name="android:windowActionBarOverlay">true</item>
</style>
答案 4 :(得分:0)
您收到未绑定的前缀错误意味着您已完成引用库,您只需要修改xmlns属性并使slidingUpPanelLayout成为root用户即可完成。别忘了改变&#34; com.example.slidinguppanel&#34;与您的包名称。 希望它能解决你的问题。
<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>