EditText not showing up when Activity holds multiple fragments - android

For the few people looking at my previous similar question, I deleted it and moved it here to be a more specific question now that I have a greater insight to the problem.
I have an Activity that holds one fragment on my standard phone, and holds two fragments on larger devices (tablets). The Activity holds the options menu, as well as the EditText. When I use my phone, everything loads fine. When I use my tablet, the EditText is not shown in the Activity. Here is the .xml files.
Activity:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xlmns:tools="http://schemas.android.com/tools
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_margin="8dp"
android:orientation="vertical" >
<EditText
android:id="#+id/trips_editText_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/searchClients"
android:inputType="text|textNoSuggestions"
android:visibility="visible" >
<requestFocus />
</EditText>
<fragment
android:id="#+id/trips_list"
android:name="com.ib.dfm.TripsListFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:context=".TripsListActivity"
android:layout="#layout/trip_list_item" />
</LinearLayout>
Can anyone figure out why the EditText will not show up on my tablet? Also, if I try and access it programatically with findViewById I get null. Thanks.

You most likely have multiple layouts defined for your Activity and with tablet the xml file does not contain the EditText

You use fill_parent which has become deprecated, use match_parent instead. Hope it helps.

Related

How to control the drawing order of overlapping elements android activity?

I think I have tried and researched enough, if not everything, yet I just can't get the two icons on the right get displayed in android emulator.
The strange thing is, that they are perfectly visible in design window.
Moreover, with similar/same GUI design, other activities display all my elements just fine.
I already know well, that how views overlap on screen depends on order of elements as I place them in the 'Component Tree' of Android Studio IDE.
Correctly looking design in Android Studio:
Missing icons on the right in emulator:
Moreover, the app in missing the title, which could be caused by an inappropriate parent activity class (its Activity which I changed from AppCompatActivity as I spent quite some time with the AS Designing tool).
How else can I control the order of elements when they overlap?
Or what weird Android concept am I still missing?
Or what has changed since all worked fine for me?
Below is the code XML for app design:
<?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.sbm.bc.smartbooksmobile.ActivityTeacherHwkCheckByTask">
<ImageView
android:id="#+id/Problems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginTop="57dp"
android:elevation="24dp"
android:visibility="visible"
app:srcCompat="#drawable/ic_problems" />
<ImageView
android:id="#+id/Talar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="42dp"
android:layout_marginTop="57dp"
android:elevation="24dp"
android:visibility="visible"
app:srcCompat="#drawable/ic_menu_talar" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_blue_dark"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="45dp"
android:background="#android:color/holo_blue_bright">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:visibility="visible">
<LinearLayout
android:id="#+id/ListOfTaskRows"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="24dp"
android:orientation="vertical"
android:visibility="visible">
</LinearLayout>
</ScrollView>
</TableRow>
<TextView
android:id="#+id/Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="63dp"
android:allowUndo="false"
android:elevation="20dp"
android:ems="10"
android:text="Ăšloha"
android:textAlignment="center"
android:textSize="18sp"
android:visibility="visible" />
</RelativeLayout>
I think you are missing the fact that the RelativeLayout children are drawn in front of each other if they overlap. In your case you have a TableRow whose width is match_parent - it fills the parent's width but as it's added after the image views it's drawn in front of them.
You could constrain the table's width so that it leaves room for the images by setting it's layout_alignEnd attribute to the id of your left-most image, so that the table would end where the image begins.
Well, believe it or not the reason for missing icons was, that I decided to derive my app from plain Activity and not AppCompatActivity as I had it before.
So I have restored my activity to extends AppCompatActivity again and lo and behold.. It works.
This of course also enabled the Activity title again.
As its a pure nonsence (another one) and my time wasted counts already in days (not only this issue, but many other crappy designs and apparent bugs in ADT), I've just decided to abbandon native Android development in the near future and switch back to Xamarin/C# instead. (I've started my Android development from C# Xamarin 4 years ago and only left because of insufficient HW access support at that time).
Howhg !
For user of "Material Design":
Another simple workaround is using "elevation" property of any GUI element.
By increasing this value, one can force to draw this element on foreground over those with lower elevation.
As a bonus (or drawback), you get shading around your elevated GUI element according to how much you have elevated.
I wonder how much this feature prolongs rendering time
Another question is min supported API version. (Did not find it right away..)

Android webview scrolling issue

How can i handle the scrolling in webview such that when cursor comes below certain line, cursor automatically scrolls above it. Is there any function because it can be handled by IOs but i am not finding anything for android.
I happy I can help you with this issue!
The solution is really simple! I'm using the same rich editor.
I was facing the same problem and I solve it removing the ScrollView.
What you have to do is on your layout create a Linear layout and inside it put the editor. Just one thing you should include as tag in Linear layout:
android:windowSoftInputMode="adjustPan|adjustResize"
This is my layout (Note: I changed the name of the control)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="115dp"
android:windowSoftInputMode="adjustPan|adjustResize"
android:background="#drawable/background_container_corner_white"
android:layout_alignParentTop="true">
<com.glaucioleonardo.wcmauditor.activities.editor.RichEditor
android:id="#+id/editor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"/>
</LinearLayout>
You don't need to use those tags in Linear layout. I just use them to format according to my app
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="115dp"
android:background="#drawable/background_container_corner_white"
android:layout_alignParentTop="true"
Now it's working perfectly! If you don't solve your problem, please post your layout and will be easier to help you!

How to make a WhatsApp like `RecyclerView`?

This may be possible of duplicate question i have tried all things none of it works i need to make whatsapp like chat model using RecyclerView and at the bottom EditText and a Button bottom my problem is i can have EditText and bottom at the bottom but i need scroll to view that EditText and Button, what i should have when user enter that page EditText and Buttonb should appear without scrolling and one more problem there is lots of space between two items in thatRecyclerView` how to reduce that space let me post what i did so far:
My Recyclerview ChatLayout:
<?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.support.v7.widget.RecyclerView
android:id="#+id/constraint_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="4">
<EditText
android:id="#+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Enter Message"
android:lines="1" />
<Button
android:id="#+id/btn_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Send" />
</LinearLayout>
</RelativeLayout>
How to do this as am new for android development someone please help me!
You should change the android:height in layout that u use in your RecyclerViewAdapter to wrap_content
And also in your manifest
<activity
...
android:windowSoftInputMode="adjustPan"
...
></activity>
Their are many libraries out there.This library is a sample Android App which can be used as a starter application for a chat application.You can take reference or implemented this library in your project
check your row item(layout xml file) which is used in your viewholder. I think you have used match_parent in your parent view. Make it as wrap_content.
For that scrolling issue, check your code for smoothScrollToPosition(int). may be you have used this method in your code.

Soft Keyboard Hiding ActionBar while using adjustPan

I need to set visible all these three items
1. ActionBar
2. ListView
3. EditText (at Bottom)
When i click on EditText, it pushed the background image and squeezed it. i saw some tutorials and used android:windowSoftInputMode="adjustPan" that solved the squeezing issue but created a new one. When the SoftKeyboard appears, it also hides the ActionBar. I have visited many questions , but none of them was actually helpfull. IS there any way to set ActionBar always visible whatever happening on screen etc...
EDITED
The xml of fragment used to display the ListView and EditText is :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#id/android:list"
style="#style/ContactListView"
android:layout_width="match_parent"
android:layout_height="389dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:isScrollContainer="false" />
<TextView
android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_above="#+id/editText1"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="#string/no_contacts"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:background="#android:color/holo_blue_dark"
android:ems="10"
android:imeOptions="flagNoExtractUi"/>
</RelativeLayout>
Edited (2nd)
Snapshots are:
Try using android:windowSoftInputMode="adjustResize|stateHidden" in your activity tag.
I have the same problem as yours with EditText inside a Relative layout before, after searching several thread all over internet I have failed, but I solve it by experimenting on it through adding bottom_padding to the EditText which fixed it.
try this code to manifest file and activity to change layout.
android:windowSoftInputMode="stateAlwaysVisible|stateHidden"

Android: Fixed Number Pad

I have an EditText and when clicked a numberpad slides up via android:inputType="number". When this happens though it pushes the TextViews above off of the screen. I was wondering if there was a way for the numberpad to always be shown (then I can have fixed positions for everything)?
(I do not have a lot on the activity, so it is not like I am trying to save space.) I want the user to be able to see the TextViews that get pushed off the screen because they are updated based on the input. Here is what it looks like:
<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"
tools:context=".Name" >
// TextViews that get pushed off
<EditText
android:id="#+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="71dp"
android:layout_toLeftOf="#+id/enter_input"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
</RelativeLayout>
Is this possible? Or is there a better way so everything is shown on the screen and so nothing is hidden?
You can add android:windowSoftInputMode="stateAlwaysVisible" to your activity in AndroidManifest.xml so it forces the keyboard to always show.
<activity android:name="[activity_path]" android:windowSoftInputMode="stateAlwaysVisible"/>

Categories

Resources