I want to add a particular layout till 14 views. So that layout can be add till 14 times not after that. I have a next destination layout after clicking on the next destination this layout should get added.
So for that I have choose fragment. Now I can add the fragment onClick of the next destination layout. But nothing happens when I again click on next destination layout. How can I add this till 14 times??
And I have a remove destination layout. OnClick of this the layout should swipe to right and should get removed by animation. How can I achieve this??
I want to do like this :
GoBoxActivity
nextDestination.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//addedDestination.setVisibility(View.VISIBLE);
//removeDestination.setVisibility(View.VISIBLE);
fragment = new NextDestinationFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
}
});
Fragment layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1.00"
android:background="#android:color/white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:id="#+id/LinearAddedDestination">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="DESTINATION"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="#drawable/shape"
android:gravity="right"
android:layout_gravity="center|right"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="80dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_clear_black_18dp"
android:layout_marginLeft="05dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="REMOVE"
android:layout_gravity="center"
android:layout_marginLeft="05dp"
android:textSize="14sp"
android:layout_marginRight="15dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="08dp"
android:background="#drawable/line2"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_place_black_48dp"
android:layout_marginTop="05dp"
android:layout_gravity="center" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableEnd="#drawable/ic_chevron_right_black_24dp"
android:layout_marginEnd="10dp"
android:text="#string/Loc"
android:layout_gravity="center"
android:layout_marginTop="05dp"
android:textAppearance="#android:style/TextAppearance.Medium"
android:cursorVisible="false"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Street/Building/Place"
android:layout_marginStart="48dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginEnd="10dp"
android:hint="#string/LocationDetails"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginStart="48dp"
android:hint="#string/HouseDetails" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_person_black_48dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="#string/additionalContact"
android:textAppearance="?android:attr/textAppearanceMedium"
android:drawableEnd="#drawable/ic_expand_more_black_24dp"
android:layout_marginTop="08dp"
android:layout_marginStart="05dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginEnd="50dp"
android:layout_gravity="center"
android:visibility="gone"
android:layout_marginTop="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Name"
android:layout_gravity="center"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Phone"
android:layout_gravity="center"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/or"
android:layout_gravity="center"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="220dp"
android:layout_height="40dp"
android:background="#drawable/shape"
android:layout_gravity="center_horizontal">
<ImageButton
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/phone2"
android:layout_gravity="center"
android:layout_marginStart="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/addFromContacts"
android:layout_gravity="center"
android:layout_marginStart="20dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginLeft="48dp"
android:hint="#string/contact1"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginEnd="10dp"
android:hint="Instruction"
android:layout_gravity="center"
android:layout_marginLeft="10dp" />
</LinearLayout>
</LinearLayout>
Can anyone help please..?
You need to implement a FragmentAdapter in order to manage multiple fragments. Then you have to inflate those fragments in some sort of ListView or ViewPager. Have a look at this or that tutorial.
Using an OnTouchListener you are able to implement the swipe gestures to remove your fragments from List/Pager.
Hope this helps. Cheers
You should use fragmentManager.beginTransaction().add(R.id.container, fragment) to add new Fragment and use remove() to remove it.
For animation,you can use fragmentManager.beginTransaction(). setTransition() to set the animation that Android offers when fragment is added,removed.If you want to implement custom animation,you can use fragmentTransaction.setCustomAnimations(enterAnimation,exitAnimation),and write the two animation in your XML file.
Hope this can help you.
Related
I am trying to set my admob banner on bottom of the screen but it's not showing. I have tried all possible way to set it as bottom but I am unable to set it...its going down side of expandable list view.
My XML is like below...let me know if someone can help me to sort out issue.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e7e7e7"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<include
layout="#layout/top_points_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/five">
</View>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="#dimen/laytop_imgwidthheight"
android:layout_height="#dimen/laytop_imgwidthheight"
android:contentDescription="#string/app_name"
android:src="#drawable/app_icon"
android:visibility="gone" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:gravity="left"
android:padding="#dimen/five"
android:text="Country of Purchase"
android:textColor="#color/Gray"
android:textSize="18sp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/layout_country_selection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="5dp"
android:background="#drawable/list_item_background"
android:orientation="horizontal"
android:padding="6dp">
<com.commonutility.RoundImageView
android:id="#+id/imageView_country_logo"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/country_default_logo"
android:visibility="visible" />
<TextView
android:id="#+id/textView_country_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_toRightOf="#+id/imageView_country_logo"
android:padding="5dp"
android:text="Select Your Country"
android:textColor="#color/Blue"
android:textSize="19sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="5dp"
android:padding="3dp"
android:src="#drawable/dropdown" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/five"
android:layout_weight="1"
android:gravity="right"
android:paddingBottom="#dimen/five"
android:paddingTop="#dimen/five"
android:text="Country"
android:textColor="#fe4080"
android:textSize="#dimen/rewards_countrytextsize"
android:textStyle="bold" />
<TextView
android:id="#+id/txtcountry"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="left"
android:paddingBottom="#dimen/five"
android:paddingTop="#dimen/five"
android:text="USA"
android:textColor="#color/material_color_primary_dark"
android:textSize="#dimen/rewards_countrytextsize"
android:textStyle="bold" />
</LinearLayout>
<ExpandableListView
android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/list_item_background"
android:cacheColorHint="#android:color/transparent"
android:divider="#color/md_white_1000"
android:dividerHeight="0dp"
android:groupIndicator="#null"
android:scrollbars="none" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:clickable="false"
android:nestedScrollingEnabled="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/banner_home_footer">
</com.google.android.gms.ads.AdView>
</LinearLayout>
Let me know what is wrong in this.
Thanks :)
android:layout_alignParentBottom="true"
works only in RelativeLayout, but it's inside a LinearLayout.
You could change the root layout to RelativeLayout and wrap everything but your AdView inside another LinearLayout (or better handle the behaviour of the other views as expected inside a RelativeLayout to avoid deep layouts).
I'm making a layout:
Here is a code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#373c5c"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout android:id="#+id/list_offer_item_container"
android:layout_marginTop="15dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/shape"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:id="#+id/imgcreditcompany"
android:layout_width="36dp"
android:layout_marginRight="4dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:contentDescription="#string/app_name"
android:layout_height="36dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/txtname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="1dp"
android:textColor="#48899f"
android:textSize="#dimen/textsizeearncredit_title"
android:text="Name"
android:textAllCaps="false"
android:textStyle="normal|bold" />
<TextView
android:id="#+id/txtdesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="1dp"
android:maxLines="1"
android:textColor="#80869c"
android:textSize="#dimen/textsizeearncredit_desc"
android:text="This is a description of the offer and this is just a demo to show off 3 lines stacking correctly on top of each other"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="20dp"
android:gravity="end"
android:layout_gravity="center_vertical">
<TextView android:id="#+id/list_offer_badge_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/list_offer_item_container"
android:textColor="#color/md_amber_700"
android:textSize="12sp"
android:visibility="gone"
android:text=""/>
</LinearLayout>
<ImageView
android:id="#+id/nextArrow"
android:layout_alignParentRight="true"
android:tint="#color/md_grey_300"
android:rotation="180"
android:layout_width="32dp"
android:visibility="gone"
android:layout_marginRight="16dp"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_height="32dp"
android:contentDescription="#string/app_name"
android:padding="#dimen/two" />
</LinearLayout>
</RelativeLayout>
How to add an text above the 'button style' linear layout?
I want for example "Hello dear user! Check it below".
Where put textview, where add more layout or whatever?
It is very simple!
You have to add TextView, with id (text, for example) and, in your LinearLayout you need to add line android:layout_below="#+id/text". Optional, you can specify attribute android:layout_alignParentTop="true" in TextView.
Just use code below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#373c5c"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/text"
android:text="Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
<LinearLayout android:id="#+id/list_offer_item_container"
android:layout_below="#+id/text"
android:layout_marginTop="15dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/shape"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:id="#+id/imgcreditcompany"
android:layout_width="36dp"
android:layout_marginRight="4dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:contentDescription="#string/app_name"
android:layout_height="36dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/txtname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="1dp"
android:textColor="#48899f"
android:textSize="#dimen/textsizeearncredit_title"
android:text="Name"
android:textAllCaps="false"
android:textStyle="normal|bold" />
<TextView
android:id="#+id/txtdesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="1dp"
android:maxLines="1"
android:textColor="#80869c"
android:textSize="#dimen/textsizeearncredit_desc"
android:text="This is a description of the offer and this is just a demo to show off 3 lines stacking correctly on top of each other"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="20dp"
android:gravity="end"
android:layout_gravity="center_vertical">
<TextView android:id="#+id/list_offer_badge_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/list_offer_item_container"
android:textColor="#color/md_amber_700"
android:textSize="12sp"
android:visibility="gone"
android:text=""/>
</LinearLayout>
<ImageView
android:id="#+id/nextArrow"
android:layout_alignParentRight="true"
android:tint="#color/md_grey_300"
android:rotation="180"
android:layout_width="32dp"
android:visibility="gone"
android:layout_marginRight="16dp"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_height="32dp"
android:contentDescription="#string/app_name"
android:padding="#dimen/two" />
</LinearLayout>
</RelativeLayout>
Above
<LinearLayout android:id="#+id/list_offer_item_container"
put your TextView or whatever you want. So something like
<TextView android:id="#+id/myTV"
// other attributes />
Then in
<LinearLayout android:id="#+id/list_offer_item_container"
add android:layout_below="#id/myTV"
By default, RelativeLayout puts it's elements at the top-left until you specify otherwise. So adding this will put your LinearLayout below the TextView.
I think the confusion is on how RelativeLayout and LinearLayout work. You have orientation in your RelativeLayout which does nothing. RelativeLayout puts it's elements in the order you tell it by the attributes such as layout_below and layout_above. LinearLayout, however, adds them in the order in which they show in the xml file which is why orientation matters in LinearLayout but not RelativeLayout.
You'll want to look at RelativeLayout.LayoutParams and other parts of the documentation to better understand how the layouts work and which is best in your specific cases.
I have an image and some text and below that i have a sliding tab layout with a view pager and the view pager has 3 fragments each having one recycler view each . Now my problem is that i want to scroll the recyclerview and at the same time i want to scroll the rest of the elements too. For eg when i scroll the recycler view i want all other views to scroll as well. This my XML layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView7"
android:src="#drawable/aal"
android:adjustViewBounds="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#98000000"
android:id="#+id/innerColor"
android:layout_alignBottom="#+id/imageView7"
android:layout_alignParentTop="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/include"
android:padding="13dp"
>
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:clickable="true"
android:background="#drawable/custom_bg"
android:onClick="BackPressed"
android:src="#drawable/ic_arrow_back"
android:id="#+id/imageView2" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:clickable="true"
android:src="#drawable/add"
android:id="#+id/addAction"
android:onClick="showImage"
android:background="#drawable/custom_bg"
android:tint="#color/icons"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sample "
android:textSize="22sp"
android:id="#+id/textHeader"
android:textColor="#ffffff"
android:layout_marginLeft="12dp"
android:scaleType="centerCrop"
android:layout_above="#+id/descText"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:id="#+id/descText"
android:layout_marginLeft="12dp"
android:text="Sampletext"
android:layout_above="#+id/Fbutton"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Follow"
android:onClick="followUnfollow"
android:background="#drawable/follow_button_bg"
android:stateListAnimator="#null"
android:textColor="#403e3e"
android:padding="5dp"
android:id="#+id/Fbutton"
android:layout_alignParentBottom="true"
android:layout_marginBottom="150dp"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Fbutton"
android:layout_marginTop="-80dp"
android:id="#+id/relativeLayout5"
android:layout_centerHorizontal="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatMem"
android:layout_alignTop="#+id/relativeLayout5"
android:layout_toEndOf="#+id/relativeLayout5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numImages"
android:text="500"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/texts"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="PHOTOS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numImages"
android:layout_centerHorizontal="true" />
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#ffffff"
android:layout_marginLeft="80dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatFol"
android:layout_alignTop="#+id/relStatMem"
android:layout_toEndOf="#+id/relStatMem">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numMembers"
android:text="5"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textsMembers"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="MEMBERS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numMembers"
android:layout_centerHorizontal="true" />
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#ffffff"
android:layout_marginLeft="80dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatFols"
android:layout_alignTop="#+id/relStatFol"
android:layout_toEndOf="#+id/relStatFol">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numFolls"
android:text="1B"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textsFol"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="FOLLOWERS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numFolls"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<!--In addition to the two java files we got from google git , this is what you need for tabs-->
<com.example.skmishra.plates.Library.SlidingTabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_below="#+id/innerColor"
android:layout_height="wrap_content">
<!--For elevation add here-->
</com.example.skmishra.plates.Library.SlidingTabLayout>
<android.support.v4.view.ViewPager android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/tabs"
android:id="#+id/viewPager"
android:fillViewport="false">
</android.support.v4.view.ViewPager>
</RelativeLayout>
</ScrollView>
Google + Does that , i would like to implement something simillar
I believe Google used a Collapsing Toolbar Layout, which will collaps the toolbar on scroll or other events.
You can find more information here.
<android.support.design.widget.AppBarLayout
android:layout_height="192dp"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
I was having some problem with the layout of Android Activity. So basically I have a navigation drawer and two Activity. The layout was working perfectly when I wrap all of them with a frame layout. However, because of the navigation drawer issues, I have to remove the frame layout into another xml layout. And then from there, my layouts were all messed up. Here is my layout.xml:
<LinearLayout 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"
android:orientation="vertical">
<com.esri.android.map.MapView
android:id="#+id/map"
android:layout_width="fill_parent"
android:layout_height="100dp"
initExtent="21801.3, 25801.0, 33218.7, 44830.0" >
</com.esri.android.map.MapView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_marginLeft="45dp" >
<ImageView
android:id="#+id/ivEventGuide"
android:layout_width="230dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:src="#drawable/event_create_guide"
android:visibility="gone" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/btnNewsFeed"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/lightred"
android:minHeight="20dp"
android:paddingBottom="5dp"
android:text="News feed"
android:textColor="#FFFFFF"
android:textSize="13dp" />
<LinearLayout
android:id="#+id/llNewsFeed"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/btnNewsFeed"
android:background="#FFFFFF"
android:orientation="vertical"
android:visibility="gone" >
<ListView
android:id="#+id/EventNewsFeedListview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="#F6CECE" >
</ListView>
</LinearLayout>
<Button
android:id="#+id/btnLegends"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btnNewsFeed"
android:background="#FFFFFF"
android:minHeight="20dp"
android:paddingBottom="5dp"
android:text="Legends"
android:textColor="#color/lightred"
android:textSize="13dp" />
<LinearLayout
android:id="#+id/legendDiv"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="#+id/btnLegends"
android:background="#fff"
android:orientation="vertical"
android:visibility="gone" >
<TableLayout
android:id="#+id/tableEvent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp" >
<ImageView
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/food" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingTop="10dp"
android:text="Food Event"
android:textColor="#000"
android:textSize="10dp" />
<ImageView
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/sport" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingTop="10dp"
android:text="Sport Event"
android:textColor="#000"
android:textSize="10dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="2dp" >
<ImageView
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/races" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingTop="10dp"
android:text="Festival Celebration"
android:textColor="#000"
android:textSize="10dp" />
<ImageView
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/discussion" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingTop="10dp"
android:text="Chit Chat Session"
android:textColor="#000"
android:textSize="10dp" />
</TableRow>
</TableLayout>
</LinearLayout>
<TextView
android:id="#+id/tvSearchTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/llSearch"
android:background="#color/lightred"
android:gravity="center"
android:paddingBottom="5dp"
android:text="Address Search"
android:textColor="#FFFFFF" >
</TextView>
<LinearLayout
android:id="#+id/llSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#FFFFFF"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="1" >
<EditText
android:id="#+id/searchAddrET"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="0.8"
android:hint="Enter search address, eg. postal code"
android:textSize="12dp" />
<Button
android:id="#+id/btnSearchAddr"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="0.2"
android:background="#color/lightred"
android:minHeight="30dp"
android:text="Search"
android:textColor="#FFFFFF"
android:textSize="12dp" />
</LinearLayout>
<TextView
android:id="#+id/tvDirectionTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/llDirection"
android:background="#color/lightred"
android:gravity="center"
android:paddingBottom="5dp"
android:text="Direction"
android:textColor="#FFFFFF"
android:visibility="gone" >
</TextView>
<LinearLayout
android:id="#+id/llDirection"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:background="#FFFFFF"
android:padding="5dp"
android:visibility="gone" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvDirection"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TextView>
</ScrollView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
When it was working fine, I wrapped the map view and the rests of the layout with a frame layout. And then inside the class where I extended the navigation drawer:
public class EventMain extends NavigationDrawer {
public static MapView mMapView = null;
ArcGISTiledMapServiceLayer tileLayer;
LocationManager locationManager;
public static GraphicsLayer graphicsLayer = null;
public static Callout callout;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewGroup content = (ViewGroup) findViewById(R.id.event_frame);
getLayoutInflater().inflate(R.layout.event_main, content, true);
}
The problem that I was having now was all the other components is not showing on top of the map view. Any guides?
Thanks in advance.
You should consider using RelativeLayout for overlapping views. Views inside a RelativeLayout may be positioned relative to their parent and/or siblings. A LinearLayout will arrange views sequentially with no overlap allowed.
I have an edittext, and when I focus on that, the footer layout was pushed together. How to hide footer when focus on edittext.
Before focus
After focus
this is my source code
<ListView
android:id="#+id/list_chat_rom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/rl_footer_send"
android:divider="#android:color/transparent"
android:dividerHeight="5dp"></ListView>
<RelativeLayout
android:id="#+id/rl_footer_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/menu_bar_bg">
<RelativeLayout
android:id="#+id/rl_insert_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="10dp">
<ImageView
android:id="#+id/btn_send_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/layout_imv_send_message" />
<EditText
android:id="#+id/edit_insert_chat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/btn_send_msg"
android:background="#drawable/layout_edit_text_chat"
android:hint="type to filter"
android:inputType="text"
android:maxLines="1"
android:textColor="#color/black" />
</RelativeLayout>
<View
android:id="#+id/view_line"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#id/rl_insert_chat"
android:background="#color/black"></View>
<RelativeLayout
android:id="#+id/rl_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/view_line"
android:paddingBottom="5dp"
android:paddingLeft="20dp"
android:paddingRight="10dp"
android:paddingTop="5dp">
<ImageView
android:id="#+id/imv_avatar_chat"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<RelativeLayout
android:id="#+id/rl_content_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/imv_avatar_chat">
<TextView
android:id="#+id/tv_name_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="user name"
android:textColor="#color/white" />
<TextView
android:id="#+id/tv_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tv_name_user"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="lv : 10"
android:textColor="#color/white" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:src="#drawable/target_icon" />
<TextView
android:id="#+id/tv_point_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10/125" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:src="#drawable/gem_icon" />
<TextView
android:id="#+id/tv_xu_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="100" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<TextView
android:id="#+id/tv_login_facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#id/imv_avatar_home"
android:text="ĐĂNG NHẬP BẰNG FACEBOOK"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
Why don't you try to hide it?
You can try to detect the keyboard state with this :
final View activityRootView = findViewById(R.id.activityRoot);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
... do something here
}
}
});
Note : Taken from here
And then you just hide the view that you want to hide.
Try with
android:windowSoftInputMode="adjustPan"
in the Activity declaration in the manifest