Android webview scrolling issue - android

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!

Related

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.

EditText not showing up when Activity holds multiple fragments

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.

Query with layout

I have been working on layout lately. There are two image shown. First one shows what I need and Second one shows what I get.
Can anybody suggest me how to achieve this with LinearLayout.
And when I say LinearLayout that means no layout_weight or RelativeLayout need to be used. I know using these two will simplify my work, but I want why through my code its not achieved. Below is my code for XML.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mytext" />
<ImageButton
android:id="#+id/ib"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|center_vertical"
android:src="#android:drawable/ic_lock_idle_alarm"
android:contentDescription="#+id/ibutton" />
</LinearLayout>
I do this by adding a dummy View with layout_weight="1" and layout_width="0dp" between the the views I want on the left of the parent and those I want on the right. This will expand to fill the space, assuming the other views have no weight. Crude but effective.
In my opinion it is not possible to get a layout shown in 1st pic by using just one LinearLayout. Can you mention specific reason why you don't want to use RelativeLayout?
Such layouts can easily be made using single RelativeLayout. May be there is a workaround for the situation which is restricting you to use RelativeLayout/layout_weight.

Android layout:weight doesn't work on device

I'm getting two differents behavior for a ListActivity row. Eclipse Graphical Layout show the right behavior, but at runtime, on the device, the layout:weight doesn't seem to work properly and the Textview is resized to the minimum width, depending on the text property.
This is how I had setup the layout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#color/defaultBg"
android:orientation="horizontal">
<ImageButton
android:id="#+id/myButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_weight="2"
android:src="#drawable/ic_launcher"/>
<TextView
android:id="#+id/myText"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_margin="5dp"
android:background="#2288EE"
android:layout_weight="6" android:text="Hello" android:textColor="#android:color/white"/>
</LinearLayout>
EDIT: I just found that the LinearLayout doesn't fill the listRow width. I'm still trying to find how to solve
Any help will be very appreciated.
I fix the issue myself. The problem wasn't in the table row layout posted above. The problem was in the android:layout_width of the parent ListView which was set to 'wrap_content' instead of 'fill_parent'.
Thanks to everyone who offered his contribute!
In your LinearLayout put android:weightSum="8". It should do the trick, on my device works fine.
Try adding android:scaleType="fitCenter" to your ImageButton. If I'm not mistaken, your source Drawable is too big, therefore making the ImageButton take too much horizontal space.

android - last added item to layout is strech vertical. WHY? (Remake)

[Second Edited]
I found where problem is. But i dont know why its doing. It cant be margin on LinearLayout (or just marginLeft). Does anybody know why it cant have ?
[EDITED]
Hello i have xml file in layout like bellow.And iam adding TextViews from any xml layout to horizontal LinearLayout. This layout structure is given and i cant change it.
And last added TextView is streching always verticaly. I dont know why i am in tottaly despair. Too many hours i was try* that but without no idea. I know just its not in programicaly adding TextViews ..
If some body know why its doing i will be thankful.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/back_border"
>
<RelativeLayout
android:id="#+id/manager_view_table_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
>
<LinearLayout
android:id="#+id/layout_for_textViews"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="6px"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:background="#drawable/back_border"
>
<!-- horizontal layout, HERE IAM ADDING TEXTVIEWS -->
</LinearLayout>
</RelativeLayout>
<!--What is here its no important
because, there is RelativeLayout with alignBellow relative layout before -->
</RelativeLayout>
and TextView witch iam addig to LinearLayout:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingRight="7px"
android:paddingLeft="7px"
android:paddingTop="3px"
android:paddingBottom="3px"
android:layout_marginLeft="5px"
android:gravity="center_horizontal"
android:background="#drawable/background_table"
android:textColor="#330033"
android:text="Some text"
/>
Try to replace the android:layout_margin="6px" from the LinearLayout by android:padding="6px".
I think this will solve your problem. I mean the new LInearLayout should be like this:
<LinearLayout
android:id="#+id/layout_for_textViews"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6px"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:background="#44ff435f"
>
I am confused with your three layouts. Wat's the porpose of all thses nested layouts, try to recreate the text views with a single relative layout, and use the android:layout_above and android:layout_below for placing the text views.
First of all you need to refactor this code.
You might want to use actual ListView to create repeated elements.
and why is xmlns:android="http://schemas.android.com/apk/res/android" declared thrice in this xml code, when it is actually required just once at top root element.
Even with this layout to solve your problem, if other things are not working a nice idea would be to switch to Graphic layout(bottom tab in eclipse when on .xml file) and manually try to set the third TextView (not listview) height manually, you can observe the changes then and finalize them accordingly..

Categories

Resources