<?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="match_parent">
<ViewFlipper
android:layout_width="match_parent"
android:layout_height="match_parent"
android:flipInterval="1000"
android:autoStart="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/wow_image"
android:contentDescription="#string/app_name" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/transparent_water"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/tr"/>
</ViewFlipper>
</RelativeLayout>
I'm using this xml its working fine but it takes time to load slider.And I want to use 4 to 5 images more.Any suggestions
I actually get at the of running and starting the app
replace your code with this
<?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="match_parent">
<ViewFlipper
android:layout_width="match_parent"
android:layout_height="match_parent"
android:flipInterval="500"
android:autoStart="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/wow_image"
android:contentDescription="#string/app_name" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/transparent_water"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/tr"/>
</ViewFlipper>
</RelativeLayout>
Add these line :
viewFlipper.setFlipInterval(YOUR TIME);
Related
I have an app that has been running on my deivce perfectly fine for a long time. Today I decided to test it on an older device. I have an old Glaxy S4 Mini, so I loaded it up, and an entire part of my layout was missing. The missing part is a reusable layout I made, and included it in this activity. The space where it would be is not taken up by anything, it is just left empty
This is the activity layout file. Everything that is inside of include is completely missing when the app is ran.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.eddie.songsPrimirenya.SearchActivityReg">
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/search_bar_include"
layout="#layout/search_bar"
/>
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyclerViewReg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/search_bar_include"
android:layout_margin="3dp"/>
</RelativeLayout>
and this is the layout that I was including earlier. I think it's not showing because of some compatibility issue, but I do not know what it is.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/cardSearchReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
card_view:cardCornerRadius="5dp"
card_view:layout_constraintBottom_toBottomOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toTopOf="parent"
card_view:layout_constraintVertical_bias="0.0">
<RelativeLayout
android:id="#+id/LayoutAll"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/LayoutSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/txtInReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:hint="#string/search"
android:singleLine="true"
android:textColorHint="#color/textHint" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/LayoutSearchModeSelect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LayoutSearch"
android:layout_marginStart="3dp">
<Switch
android:id="#+id/swtSearchType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="false"
android:text="#string/search_by_name"
android:textColorHighlight="#color/colorAccent"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
Here is an image of how it is supposed to look like
and this is what it ends up looking like
make your include layout match parent,it should work fine
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.eddie.songsPrimirenya.SearchActivityReg">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/search_bar_include"
layout="#layout/search_bar"
/>
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyclerViewReg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/search_bar_include"
android:layout_margin="3dp"/>
</RelativeLayout>
Check Following Image.
![background activity content showing while opening keyboard or close. first layout goes up it take mili second to open keyboard.
Below Address field white part there is background activity content.]1
Manifest File
android:windowSoftInputMode="stateAlwaysHidden"
Here its my layout top Views. Help me to resolve this issue.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:clickable="true">
<include
android:id="#+id/top_bar"
layout="#layout/top_bar_steps_form" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/top_bar">
<FrameLayout
android:id="#+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:visibility="visible">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<LinearLayout
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|bottom"
android:orientation="vertical"
android:visibility="visible">
</LinearLayout>
</RelativeLayout>
</ScrollView>
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
i was using Transparent theme Theme.AppCompat.Translucent
i just change theme and it fixed
in my android app I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/news_tab"
android:clipToPadding="false">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listaNews1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="#color/transparent"></ListView>
<LinearLayout
android:id="#+id/ll_news_empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/news_icon"
android:tint="#color/gray_dark"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nessuna news da mostrare"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/gray_dark"/>
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
And programmatically I have this code to add the empty view:
...
listaNovità = (ListView)view.findViewById(R.id.listaNews1);
listaNovità.setEmptyView(view.findViewById(R.id.ll_news_empty_view));
...
But executing the code on emulator I see an empty layout (the listview is empty and the empty view is not showing).
What is the reason and how can I fix the problem?
Thanks everyone wants to help me.
I have a problem with this Recycle View on this layout, it don't take the complete height of your father container.
I used the weight parameters, but that is not the problem i think.
Check the code and Print screen.
Thanks in advance.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.RecyclerView
android:id="#+id/subjects"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layoutManager="android.support.v7.widget.GridLayoutManager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="horizontal"
tools:listitem="#layout/item_subject_tab" />
<RelativeLayout
android:id="#+id/usageStatusListContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:background="#color/colorLight">
<ListView
android:id="#+id/chapters"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#color/colorLight"
tools:listitem="#layout/item_chapter_usage_status"/>
</RelativeLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Layout
Here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="horizontal">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="10dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/content_main">
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"></include>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyclerView"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#ffffff"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="#+id/threadRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
</LinearLayout>
The main reason I did this design was to try to display the
<android.support.v7.widget.RecyclerView
android:id="#+id/threadRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
properly. However, when it is not being displayed at all. Before adding the two relativelayouts, I have one relative layout and the recyclerview did display, but it match_parent for every item of the list and was not able to fix it. How can I display my view properly?
The problem probably has to do with the layout_height="wrap_content" on your RecyclerView. You need to use setAutoMeasureEnabled(true) for wrap_content to work properly with a RecyclerView.
Here's an example:
RecyclerView threadRecyclerView = (RecyclerView)findViewById(R.id.threadRecyclerView);
threadRecyclerView.getLayoutManager().setAutoMeasureEnabled(true);
And your your XML should look something like this:
<android.support.v7.widget.RecyclerView
android:id="#+id/threadRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:layoutManager="LinearLayoutManager"/>
Hope that helps. :)
Note that setAutoMeasureEnabled only works properly for Android Support Library +23.2