I want to develope screen like the below..which contains two tabs with right alignment!
actually it's the dynamic screen and top part should be fixed with two tabs when ever they click the tabs it's different fragment. please suggest me the best way.
You can use ViewPager for this.
<android.support.v4.view.ViewPager
android:id="#+id/vpPager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
Here is a link for your reference.
Design two different layout files and switch them on Tabchange.
You can either use RadioGroup to act like tabs with fragments
like this https://stackoverflow.com/a/17541555/3020568
OR you can use PagerSlidingTabStrip library and customize it like the way you want
https://github.com/astuetz/PagerSlidingTabStrip
Related
I am using Google's new TabLayout from design support library and was wondering how can I center active tab inside that layout.
Currently I am centering whole layout like this:
<android.support.design.widget.TabLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
And now I would like to center active tab inside of that layout. Something like how it was done before TabLayout. No matter how many tabs were there, active one was always in center. How can I accomplish that? Thank you.
Need to use padding for SlidingTabStrip
Look here: https://stackoverflow.com/a/36886331/651770
I'm new to Android development and I have to build an Android version of a iOs app. I have to build an horizontal menu in the bottom of the screen. Something like MOVIES|TV SHOWS|PERSONAL VIDEOS in this image
How do you suggest me to proceed? If I did an activity layout with a tabbed o linear layout at the bottom and fragments for the above contents?
#Ivan Lasorsa :
You can use ViewPager Fragment as main layout and for individual pager views we use Fragments. The tabs are part of Action Bar.
Swipe-view should consume the entire layout, then your layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
So please take a look Android Tab Layout with Swipeable Views Here . I hope it will helps you .
It's the tabbed activity, here is the doc ;)
I don't recommend bottom tab bar
because it causes the wrong touch
Pure-Android : http://developer.android.com/design/patterns/pure-android.html
but if you have to implement, you can read to
https://stackoverflow.com/a/7431480/2530660
Is there an easy way to switch between the displayed view in a ViewSwitcher in the Android Studio preview, or is the only way to swap out the XML for the sub-views one at a time?
Unfortunately, there are no XML attributes or any option on Android Studio which can help you to define the displayed view.
A similar question for the ViewFlipper was asked here (they both are direct subclasses of ViewAnimator).
However, if and only if your views are large as the screen, you could use the include tag, for example:
<ViewSwitcher
android:id="#+id/myViewSwitcher"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="#layout/first_view">
</include>
<include
layout="#layout/second_view">
</include>
</ViewSwitcher>
Then you can see your layouts in a separate XML file.
First of all if you are thinking to use ViewSwitcher, just for showing ProgressDialog then you are not doing it in a way in which it should be.
ViewSwitcher generally used to change layout of Activity. In your case ProgressDialog is not a View of your Activity rather it is just small helper which indicates some process is doing. So In short ViewSwitcher should be use somewhere where you want to alter complete screen of Activity.
In your case you can divide your layout into smaller layout files and group them using merge or include.
Create separate files for all different screens which will define UI of your Activity and group them using include.
For an example we can create small App for Introduction thing using ViewSwitcher -
First Screen - my_product.xml - this layout will define something about product.
Second Screen - about_us.xml - this layout will describe about your company.
Third Screen - thank_you.xml - to say thank you to your users.
Group them in any container View.
<ViewSwitcher
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="#layout/my_product"/>
<include
layout="#layout/about_us"/>
<include
layout="#layout/thank_you"/>
</ViewSwitcher>
ViewPager can easily solve your issues.
ViewPager (it can hold multiple views). ViewPager is kind of Array Container for View objects. You can have ViewPager rotation (like you do the array rotation) or other techniques to swap inside views. And, you can create your each inside views based on the Factory DP, so that there happens less processing (shares common resources).
They have mentioned swiping views here (Note: you just need own view swiping techniques if you don't want to use default ViewPager rotation).
Creating swipes: https://developer.android.com/training/implementing-navigation/lateral.html
ViewPager for screen slides: https://developer.android.com/training/animation/screen-slide.html
I am trying to figure out how to make a swipe view without a tab layout.
In the figure above,
1. I want to make a swipe view that can navigate page left and right.
2. Icon 1 is a global menu that needed to be there all the time while swipping.
3. Icon 3 is a bottom bar. How can I make like that way?
Any kind of suggestions and tutorial links would be appreciated. Thanks in advance.
i don't have any links for the same,but still i will tell you the very simple logic to create:
1.First remove the title bar using
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
2.Use the following Structure
<RelativeLayout>
<ViewPager android:layout_height="fill_parent"
android:layout_width="fill_parent"> //full screen
<RelativeLayout android:id="#+id/header"> -->for header
android:layout_alignParentTop="true"
</RelativeLayout>
<RelativeLayout> -->for inicators
android:below="#+id/header"
</RelativeLayout>
<RelativeLayout> --> for footer
android:layout_alignParentBottom="true"
</RelativeLayout>
</ViewPager>
</RelativeLayout>
3.now make the images for header and footer and set as background.
4.for view pager indicator go Through This Post.just download it and import in your eclipse and set as a lib in your project. how to use circle pager indicator Check My Answer.
and you are done now!!
You can simply use for example a ViewPager as explained in the official documentation because it's not mandatory to have tabs.
http://developer.android.com/training/animation/screen-slide.html
There's a full example available in that link.
If you need also to display dots for your slides, you can take advantage of this library as pointed out by other users: http://viewpagerindicator.com/
Check this library I think this is what you need
and you can customize it as per your needs
https://github.com/pakerfeldt/android-viewflow
in my application I would create a new layout, like the standard Android where you see the clock, battery, etc. That Is, it opens with the slide of the finger on the screen. How do I proceed?
You need to use a ViewPager
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/myfivepanelpager"
android:background="#234567"/>
See: http://developer.android.com/reference/android/support/v4/view/ViewPager.html
You can also do a ViewPager solution as Fragments. This is the way to go.