【问题标题】:Unable to add LinearLayout as a first child in Umano's AndroidSlidingUpPanel无法在 Umano 的 AndroidSlidingUpPanel 中将 LinearLayout 添加为第一个子项
【发布时间】: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


    【解决方案1】:

    通过添加关闭布局:

    </RelativeLayout>
    

    之后

    </com.sothree.slidinguppanel.SlidingUpPanelLayout>
    

    【讨论】:

    【解决方案2】:

    请检查您的应用对 Umano library 的使用情况。这里很清楚地写着,slidingUpPanel 视图中应该有确切的两个布局作为子布局。你可以把它当作任何布局。

    我已经用 RelativeLayoutLinearLayout 尝试过同样的事情,它就像魅力一样。

    如果您的问题没有由此解决,请告诉我。

    享受编码... :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多