创建可拖动用户界面的Android库:Draggable Panel
jopen
10年前
Draggable Panel是一个Android库创建用于构建一个可拖动的用户界面,类似于新的油Tube可拖动视频组件,基于Fragments 或Views。
Screenshots
用法:
To use Draggable Panel library and get your new awesome UI working you can use two different Android widgets:
- 1. Add
DraggablePanel
widget to your layout. Configure the view customization elements using styleable attributes or programatically and configure your fragments to work as top or bottom fragment inside theDraggablePanel
widget.
<com.github.pedrovgs.DraggablePanel android:id="@+id/draggable_panel" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
private void initializeDraggablePanel() throws Resources.NotFoundException { draggablePanel.setFragmentManager(getSupportFragmentManager()); draggablePanel.setTopFragment(placeFragment); draggablePanel.setBottomFragment(mapFragment); draggablePanel.initializeView(); }
- 2. Add
DraggableView
widget to your layout. Configure the view to use two children views as the draggable view and the second view. Configure the customization elements using styleable attributes or programatically.
<com.github.pedrovgs.DraggableView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:draggable_view="http://schemas.android.com/apk/res-auto" android:id="@+id/draggable_view" android:layout_width="fill_parent" android:layout_height="fill_parent" draggable_view:top_view_id="@+id/iv_fan_art" draggable_view:bottom_view_id="@+id/lv_episodes" draggable_view:top_view_x_scale_factor="@dimen/x_scale_factor" draggable_view:top_view_y_scale_factor="@dimen/y_scale_factor" draggable_view:top_view_margin_right="@dimen/top_fragment_margin" draggable_view:top_view_margin_bottom="@dimen/top_fragment_margin" android:background="@color/black"> <!-- ListView Episodes --> <ListView android:id="@+id/lv_episodes" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/iv_fan_art" style="@style/episodes_list_view"/> <!-- TvShow Fan Art --> <ImageView android:id="@+id/iv_fan_art" android:layout_width="fill_parent" android:layout_height="@dimen/tv_show_fan_art_height" android:layout_alignParentTop="true" style="@style/image_view"/> </com.github.pedrovgs.DraggableView>
定制
您可以编程自定义某些视图效果,或使用XML设置样式属性。自定义元素是:
- Draggable view / fragment height.
- Draggable view X scale factor.
- Draggable view Y scale factor.
- Draggable view margin right applied when the view is minimized.
- Draggable view margin bottom applied when the view is minimized.
- Enable or disable the horizontal alpha effect applied while the view is being horizontally dragged.