gravity top and set layout_height issue
Created by: mustafaerturk
if gravity is bottom everything work perfect but change gravity bottom to top sliding panel not work correctly.
public class DemoActivity extends Activity implements OnClickListener {
Button openButton;
SlidingUpPanelLayout layout;
RelativeLayout panelLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.activity_demo);
openButton = (Button) findViewById(R.id.open_panel);
openButton.setOnClickListener(this);
panelLayout=(RelativeLayout)findViewById(R.id.panel_view);
layout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
layout.setShadowDrawable(getResources().getDrawable(R.drawable.above_shadow));
layout.setSlidingEnabled(false);
layout.setEnableDragViewTouchEvents(true);
}
@Override
public void onClick(View v) {
if (!layout.isExpanded()) {
layout.expandPane();
openButton.setText("close");
} else {
layout.collapsePane();
openButton.setText("open");
}
}
demo.xml
<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="top"
sothree:collapsedHeight="68dp"
sothree:shadowHeight="4dp">
<TextView
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#ffd700" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#003366"
android:id="@+id/panel_view">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
android:id="@+id/container">
<Button
android:id="@+id/open_panel"
android:layout_width="68dp"
android:layout_height="68dp"
android:textSize="16sp"
android:textStyle="bold"
android:text="open"
android:layout_centerVertical="true"/>
</RelativeLayout>
</RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>