Footer not responding in PreferenceScreen - java

I've tried to add my footer in my preference screen, but my buttons in it are not responding. Also, when I call the EditTextPreference, my footer moves too.. Any idea?
Here's my xml file
<?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">
<include layout="#layout/footer"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/footer">
<ListView
android:id="#+id/android:list"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_weight="1" >
</ListView>
</RelativeLayout>
</RelativeLayout>

Use your layout like 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">
<include
android:id="#+id/your_footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="#layout/footer" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/your_footer">
<ListView
android:id="#+id/android:list"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_weight="1" >
</ListView>
</RelativeLayout>
</RelativeLayout>

Related

How to make ListView resizable?

Picture 1
Picture 2
How to make ListView resizable?
This ListView is OK.
OK ListView 1 Picture
OK ListView 2 Picture
I have tried all the layouts. That doesn't help.
I have a fragment container:
<?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"
android:background="#color/yellow"
tools:context=".MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/fragmentsContainer"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:menu="#menu/menu"
android:id="#+id/bottomNavigation"
android:layout_alignParentBottom="true" />
</RelativeLayout>
OK Layout is Search Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/yellow"
android:id="#+id/searchAndListViewContainer"
android:orientation="vertical">
<SearchView
android:id="#+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorOfSearchView" />
<ListView
android:id="#+id/downloadedMusicListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
unadabtable Layout :
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/darkGreen">
<ListView
android:id="#+id/musicListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
As you see Java Code will change Fragments container's inner content.
Two fragments are almost identical.
What's the problem?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<ListView
android:id="#+id/lv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/tv_footer"
android:layout_below="#+id/tv_header" />
<TextView
android:id="#+id/tv_footer"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#ff0000"
android:gravity="center"
android:text="Footer" />
<TextView
android:id="#+id/tv_header"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#00ff00"
android:gravity="center"
android:orientation="vertical"
android:text="Header" />
</RelativeLayout>
you can do that in multiple ways. here you can set your own view as header and footer.

Swipe Refresh Layout and a WebView in a ScrollView

I have a header text and a webView in a LinearLayout in a ScrollView. I want to add a Swipe Refresh Layout, but I don't know where should I place it because I always get errors or the page is not displayed.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="#style/PageTitle"
android:text="#string/news_in_fazekas" />
<WebView
android:id="#+id/newsWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Try this way I hope it will work for you.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="#style/PageTitle"
android:text="#string/news_in_fazekasx" />
<WebView
android:id="#+id/newsWebView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>

How to include layout at the bottom of another layout

step.xml:
<?xml version="1.0" encoding="utf-8"?>
<com.stepstone.stepper.StepperLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/stepperLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:ms_stepperType="dots" />
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="3dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="3dp">
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/firstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="11"
android:maxLines="1"
android:hint="First name"
android:textColor="#000000"
android:maxLength="15"
android:tag="#+id/first_name"
android:textCursorDrawable="#null" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<include
android:id="#+id/bottom_Menu"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/step"/>
</ScrollView>
This is the design of step.xml
This is the design of activity_main. In this I have included the step.xml
I need the output like this.
When I am trying to include step.xml in activity_main, I get the exception "Scroll view can only host one child view." Please help me.
Change your StepperLayout hight to wrap content.
step.xml :
<?xml version="1.0" encoding="utf-8"?>
<com.stepstone.stepper.StepperLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/stepperLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_stepperType="dots" />
And change activity_main layout as following :
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/profile_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:windowSoftInputMode="adjustResize|adjustPan">
<LinearLayout
android:id="#+id/profile_layout_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="#+id/layout_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="70dp"
android:paddingTop="3dp">
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/firstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="11"
android:maxLines="1"
android:hint="First name"
android:textColor="#000000"
android:maxLength="15"
android:tag="#+id/first_name"
android:textCursorDrawable="#null" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
<RelativeLayout
android:id="#+id/btn_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true">
<include
android:id="#+id/bottom_Menu"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/step"/>
</RelativeLayout>
</RelativeLayout>
Use this code: Once the scroll view tag has ended add the step xml code like this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_alignParentBottom="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Button1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Button2"/>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/buttons">
<!--Scrollable content here-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="test text"
android:textSize="40dp"/>
</LinearLayout>
</ScrollView>
<com.stepstone.stepper.StepperLayout
android:id="#+id/stepperLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:ms_stepperType="dots" />
</RelativeLayout>
You should make a single child inside a scrollview (just as the error says). Wrap all the children inside of another (let's say) LinearLayout or RelativeLayout with wrap_content for both the width and the height as well as the vertical orientation.
From the Docs:
A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.
EDIT
Simplest example can be like this:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
// all the views currently in your ScrollView
</LinearLayout>
</ScrollView>
StepperLayout hight is match parent that's why it is in top position, Change you StepperLayout hight to wrap content
step.xml
<?xml version="1.0" encoding="utf-8"?>
<com.stepstone.stepper.StepperLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/stepperLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_stepperType="dots" />
And ScrollView having only one child so move your include layout inside relative layout and add android:fillViewport="true" to ScrollView
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:fillViewport="true"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="3dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="3dp">
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/firstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="11"
android:maxLines="1"
android:hint="First name"
android:textColor="#000000"
android:maxLength="15"
android:tag="#+id/first_name"
android:textCursorDrawable="#null" />
</android.support.design.widget.TextInputLayout>
<include
android:id="#+id/bottom_Menu"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/step"/>
</RelativeLayout>
</ScrollView>

Layout not move up or panned when soft keyboard is shown in android java

I want to resize or pan layout when keyboard is displayed.
Here's my source code.
activity_forget_password.xml
<?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"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/forgot_password_bg"
android:scaleType="fitXY"
android:largeHeap="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp">
<com.opkix.app.utils.OpenSassTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/forget_password_introduce_string"
android:layout_alignParentBottom="true"
android:textColor="#android:color/white"
android:textSize="12sp"/>
</RelativeLayout>
</RelativeLayout>
manifest.xml
<activity android:name=".activities.auth.ForgetPasswordActivity"
android:windowSoftInputMode="adjustPan"
android:noHistory="true">
As you can see from my source code I added fitsSystemWindows and windowSoftInputMode.
Can anyone please help me?
add ScrollView as parent of RelativeLayout.It is not proper answer but it will work.
example
<?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"
android:fitsSystemWindows="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/forgot_password_bg"
android:scaleType="fitXY"
android:largeHeap="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp">
<com.opkix.app.utils.OpenSassTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/forget_password_introduce_string"
android:layout_alignParentBottom="true"
android:textColor="#android:color/white"
android:textSize="12sp"/>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>

Extend fragment container with header line

I have an activity with a fragment container for showing different details of an object in my app.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<LinearLayout
android:orientation="horizontal"
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</LinearLayout>
</LinearLayout>
This works fine. Tabs are displayed properly.
Now I want to add an header line to this actitivy which shows "static" content regardless of the current fragment for the details. The header line shall be on top with the fragment-container below. So I changed the layout to this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<LinearLayout
android:orientation="horizontal"
android:id="#+id/LabeledObjectHeaderInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderID"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".10"
android:gravity="right"
android:padding="10dip"
android:text="#string/txtHeaderID"
android:textSize="20sp" />
<TextView
android:id="#+id/txtHeaderIDValue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:gravity="left"
android:padding="10dip"
android:text="test"
android:textSize="20sp" />
<TextView
android:id="#+id/txtHeaderName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:gravity="left"
android:padding="10dip"
android:text="#string/txtHeaderName"
android:textSize="20sp" />
<TextView
android:id="#+id/txtHeaderNameValue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:gravity="left"
android:padding="10dip"
android:text="test"
android:textSize="20sp" />
</LinearLayout >
<LinearLayout
android:orientation="horizontal"
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
>
</LinearLayout>
</LinearLayout>
My problem is now, that only the header is shown, but not the content of the fragments. I only changed the layout file up to now (as you can see by the "test"-texts), but no other code.
What am I doing wrong and where is my mistake?
Try this
In your container LinearLayout you have android:orientation="horizontal" which shows its first child LinearLayout i.e the Header, but hides its second child LinearLayout i.e the content to the right.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<!-- Inner Layouts -->
</LinearLayout>
Change it to android:orientation="vertical".
<?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:layout_gravity="center">
<!-- Inner Layouts -->
</LinearLayout>
just make the orientation in your main layout vertical and it will work fine.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
Because you are making its orientation horizontal, the fragments layout goes to the right.

Categories

Resources