【发布时间】:2014-01-02 12:03:00
【问题描述】:
在AndroidSlidingUpPanel,Usage 说..
要使用布局,只需在活动布局中包含 com.sothree.slidinguppaneldemo.SlidingUpPanelLayout 作为 Root 元素。确保它有两个孩子。第一个孩子是您的主要布局。第二个孩子是向上滑动面板的布局。两个孩子的宽度和高度都应该设置为 match_parent。以下代码是库中包含的示例代码。
<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=".DemoActivity" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Main Content"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="34dp"
android:gravity="center|bottom"
android:text="The Awesome Sliding Up Panel"
android:textSize="16sp" />
<TextView
android:id="@+id/brought_by"
android:layout_width="match_parent"
android:layout_height="34dp"
android:autoLink="web"
android:gravity="center|top"
android:text="Brought to you by http://umanoapp.com"
android:textSize="14sp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="fitStart"
android:src="@drawable/graphic" >
</ImageView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
上述xml布局的结果是
我用LinearLayout(任何布局)替换了第一个子布局TextView(主要内容),它在图形布局中给出了NullPointerException。
【问题讨论】:
标签: android android-layout layout