Slide Up Panel with View Pager Title Strip - android

I am using this LIBRARY for my slide up panel. every thing is working fine with a simple layout.
Now my question is , how can I insert a pager title strip in that panel so that I can make it my View pager working on it with multiple fragments.
First image is title strip at bottom
second is slide up and sliding fragments

From your previous post, I'm assuming you're using this library (https://github.com/umano/AndroidSlidingUpPanel).
This library requires that you have 2 children views. The first one being the main layout and the second one the actual sliding view. Now, your sliding view is just a placeholder, so you can place anything you want in there. If you want to add a ViewPager, this is how you can do it.
<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" >
<SlidingUpPanelLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Top Panel -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<!-- Sliding Panel -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
</LinearLayout>
</SlidingUpPanelLayout>
</RelativeLayout>
What we have here is the main layout of our Activity (RelativeLayout) and we're adding the SlidingPanelLayout to it. Inside this Layout, we've defined our main layout to be a LinearLayout (Top Panel) and a second LinearLayout (Sliding Panel) which is the actual sliding view. Now, all we need to do is add a ViewPager to this sliding panel.

Related

Android Studio - Relative Layout on top of buttons have transparent background

I am trying to create a RelativeLayout on the top of another containing buttons in order to hide the ones below.
I have set a black background to the top RelativeLayout however, the layout is till transparent showing the objects underneath. Also The buttons behind the top relative layout are still clickable.
My question is how can I use a RelativeLayout in order to hide another one containing object underneath? The top relative layout should be NOT transparent and the buttons underneath not clickable.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:visibility="gone"
android:id="#+id/buttons"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your buttons go here -->
</RelativeLayout>
<RelativeLayout
android:id="#+id/prompt"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- your prompt -->
</RelativeLayout>
</FrameLayout>
and when you're done with your prompt relative layout, then from your activity say something like this:
View prompt = findeViewById(R.id.prompt);
prompt.setVisibility(View.GONE);
and then visible your button layout
View buttonLayout = findeViewById(R.id.buttons);
buttonLayout.setVisibility(View.VISIBLE);

DrawerLayout End gravity. Drawer not opening with edge swipe when as child

I was working on the landscape layout for my activity. In landscape activity I happen to have the layout with xml code below.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="wrap_content"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="200dp"
android:background="#android:color/holo_blue_bright"
android:layout_height="match_parent"/>
<android.support.v4.widget.DrawerLayout
android:layout_width="200dp"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:background="#android:color/darker_gray"
android:layout_height="match_parent"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_gravity="end"
android:background="#android:color/holo_red_light"
android:layout_height="match_parent"/>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
The Problem arising here is that the drawer is not opening by edge swipe. BTW using LTR layout so end is right. By java invocation for opening drawer, the Drawer opens and touch events are also handled. Also all drawers are Unlocked as well. But still Drawer doesn't opens by swipe from right edge when Drawer layout is child of linear layout with horizontal orientation. if the first Frame:ayout in the linearLayout is of zero width then the drawer works.
Whats wrong with the Drawer Layout? How Can I fix this?
From the Android reference:
DrawerLayout acts as a top-level container for window content
The DrawerLayout needs to be the root element of the view. It can't be nested in the LinearLayout

Implementation of scrollable tabs in android

I want to implement scrollable tabs in my app.
I have some content like image, some text views to show the information of the page and a viewpager that is showing the tabs at the bottom.
My problem with the viewpager is, the content keeps loading at that same place whenever I slide or click on any tab.
What I want is that:
the swipe of the tabs should be disabled and only click event should work on the tabs like buttons.
whenever I click on any tab that fragment should load in the full
page, like an activity.
How can I achieve this?
My layout xml is:
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.android.volley.toolbox.NetworkImageView
android:layout_width="match_parent" android:layout_height="200dp">
</com.android.volley.toolbox.NetworkImageView>
</RelativeLayout>
</LinearLayout>

Layout changes animations Android

I have a RelativeLayout which has a nested empty FrameLayout and a ListView below the FrameLayout. I am adding a view to the FrameLayout with animation (setting android:animateLayoutChanges="true" in xml) and I am doing this because I want it to appear at the top of my window. So it appears with the default fade in animation. The ListView on the other hand moves down, but it is not animated. What can I do for the ListView to slide down to its position, because this is not very good looking. If I have to change the way I define my views in the layout, that's ok also. I will consider every suggestion. Thx
Here is my code:
<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"
>
<FrameLayout
android:id="#+id/frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"></FrameLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/frame"
/>
</RelativeLayout>

Custom Drawer Layout - Click transparency

I use the Drawer Layout in my project. I want to customize the Drawer like the Google+ Android App. Over the "main" ListView I've added a ImageView. That's work fine. The code is:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:id="#+id/drawer_layout_relative"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="start" >
<ImageView
android:id="#+id/drawer_header_image"
android:layout_width="wrap_content"
android:layout_height="85dp"
android:src="#drawable/ic_logo_blue" />
<ProgressBar
android:id="#+id/drawer_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/drawer_header_image"
android:background="#ffffffff" />
<ListView
android:id="#+id/drawer_listview"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_below="#id/drawer_progress"
android:background="#ffffffff"
android:choiceMode="singleChoice" />
</RelativeLayout>
When you click on one of the ListView-Items a fragment load into the FrameLayout. Thats work perfectly, too.
But there is one problem. The ImageView is "clickable" too. So that, when the Drawer is open, an one will click on the ImageView the ListView (on the fragment) behind is clicked!! I don't want that. So I have try it with clickable:false on ImageView. Don't work...
For a little demo here is a video: http://www.vidup.de/v/Ao71r/
How can i make the imageview don't clickable?!
In order to keep clicks from being passed through the drawer to the view behind it, you have to setClickable to true for the view in the drawer, specifically the parent view of all the other views you have in your drawer, so that it consumes all the touch events if none of its children consume them.
Change your RelativeLayout code for drawer_layout_relative to the following (NOTE: I added android:clickable="true" to the relative layout):
<RelativeLayout
android:id="#+id/drawer_layout_relative"
android:layout_width="240dp"
android:clickable="true"
android:layout_height="wrap_content"
android:layout_gravity="start" >
By default, if a view does not handle any clicks, it lets the clicks go to the view behind it. You have an ImageView, a ProgressBar, and a ListView: The ListView handles click events, so it consumes any touches on it. The ProgressBar and ImageViews by default just display stuff and don't handle clicks to them, so the system just passes the click to the list that you have behind the drawer. Those three views are all inside a RelativeLayout. If we set that RelativeLayout to be clickable, it collects the click events that aren't handled by the ImageView and ProgressBar and it doesn't let the click events go to the view underneath it.
Think of android:clickable="true" as a way to block interaction with any view underneath the view you set this on.
For further explanation, please see this question

Categories

Resources