As shown in the image, in Microsoft Word/Powerpoint the drop-down spinner of font size enables the users to type his own choice of font size in the spinner box in addition to manually selecting one from the drop-down list.
My question is if it is possible in Android to get the "self-typing" option likewise?
Here it is. I've solved it this way.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/background_light">
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"></Spinner>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="12"
android:inputType="numberDecimal"
android:gravity="center"/>
</FrameLayout>
Related
I have a fragment that i have navigated to it using the modern Navigation UI. The problem am having is that the scroll view wont start scrolling unless the view is long. That's okay and i understand but it arises a problem where the Edit text inputs that are the bottom of the screen are being hidden when the keyboard is opened hence you can't see when you are keying in hence the reason for needing a scroll view to scroll down so that the view can be scrolled up above the keyboard
Is there a way to initiate the scroll view so that when the keyboard hides the Edit text input, i can still be able to scroll up and see what am keying in
My Navigation Host Fragment
<fragment
android:id="#+id/nav_host_fragment"
android:layout_below="#+id/app_bar_layout"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="#navigation/navigation_graph"
android:layout_above="#+id/bottom_nav"/>
My Fragment layout that has a scroll view and that its not scrolling
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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=".fragments.ScrollFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="5dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First Name"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Second Name"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Phone Number"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Gender"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="country"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="province"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="County"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="province"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="region"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="village"
android:layout_margin="5dp"/>
</LinearLayout>
</ScrollView>
If i add more view and the layout is long enough the scroll view is just working fine but its not scrolling when the views have not reached the bottom yet keyboard is hiding the view and i cant be able to see what am typing on the edit text
I have tried using Nested Scroll View and setting the
app:layout_behavior="#string/appbar_scrolling_view_behavior"
but its still not working.
I have also tried setting the following properties to the scroll view
android:isScrollContainer="false"
android:fitsSystemWindows="true"
android:fillViewport="true"
How can I make my screen scroll?
How to use ScrollView? At my activity, in it there is a picture and the text, it is necessary for me that at movement downwards or upwards the screen scroll.
The ScrollView XML resource is fairly easy to use and powerful. Just wrap whatever content you want to be scrollable in the XML with the ScrollView tags and the rest will be taken care of for you. Simple example:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:background="#color/colorPrimary"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/yourID"
android:layout_weight="1" />
...
</LinearLayout></ScrollView>
This example shows a LinearLayout filled with whatever you need (TextView in this case) that will scroll on screen when it has to.
I'm having a struggle understanding how to align layers one over another in the xml file.
I searched for a solution but couldn't find one for my needs.
I have two LinearLayout inside a RelativeLayout. The first LinearLayout contains a RecycleView/ScrollView and the second LinearLayout contains some buttons.
I want to set the second LinearLayout over the first LinearLayout, but at the bottom of the RelativeLayout. See image below.
Here is what I tested (it will extend the first layout and hide the second).
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/first"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:id="#+id/second"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/first"
android:layout_alignParentBottom="true"
app:layout_gravity="bottom">
</LinearLayout>
</RelativeLayout>
Do you have any idea how to achieve this?
PS. I don't want to use a BottomNavigationView instead of the second LinearLayout.
I managed to find a solution for my issue.
I changed the first LinearLayout with a FrameLayout and everything works as it should. Please keep in mind that the second LinearLayout must stay under the FrameLayout. Cheers!
I got the design file from GoogleCloudPlatform/appengine-endpoints-helloendpoints-android project and made small changes. I changed the theme to a dark one. I don't know how this happened but I don't see the device controls or border/frame anymore. How can I reset it? Other design files are showing alright.
Finally found the reason. When I clicked on the black outer region of the preview window, a toolbar appears above it. First button on the left is called Toggle Viewport Render Mode. This brought back my device view.
Hhmm.. For me, whenever you design/designing your layout with the parent ScrollView Layout - it will not show the toolbar and the device frame.
To show your Scrollview layout to another layout you must include it. For example :
My ScrollView.xml
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:fadeScrollbars="true"> </ScrollView>
Include it in your activity_main.xml or other .xml file.
<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"
android:fitsSystemWindows="true"
tools:context=".activities.ShareAppActivity">
<!--Include ActionBar/Toolbar-->
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/toolbar"
android:elevation="8dp"
android:minHeight="?attr/actionBarSize"
android:background="#color/colorPrimary">
</android.support.v7.widget.Toolbar>
<include
android:id="#+id/scrollview_layout"
**layout="#layout/scrollview"**
android:layout_height="match_parent"
android:layout_width="match_parent"/> </RelativeLayout>
Use the <include /> - tag and in the layout="#layout/YOUR_XML_SCROLLVIEW"
in xml layout you wish to display/include your scrollview.
You can now see your scrollview_layout with device frame and toolbar.
Click on preview window and press button 'F' on keyboard.
I have problem with xml. Why my EditText doesn't show for full screen width? It showing about 80% of screen width, but not all..
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/colorGray"
android:layout_weight=".35" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical" >
<LinearLayout
android:id="#+id/rightCont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test" />
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
Because the EditText is wrapped in a ScrollView wich takes 0.35 weight of the screen. So it will expand until it reaches the boundaries of its parent ViewGroup.
To test this, change the weight of ScrollView to 1:
android:layout_weight="1"
beside what Andy Res said, a scrollview in a scrollview is not recommended. newer android versions can handle that but older one will have trouble determining which scrollview should scroll on touch events.
Also a LinearLayout with wrap_content around the EditText with fill_parent should result in a pure wrap_content behavior of the EditText, too.
You should rethink your layout.