Search result for Question Taged android-layout
There are some results of your Tag: android-layout
    Show entire bottom sheet with EditText above Keyboard

    1. FAILURE
    2. implementing a UI where a bottom sheet will appear above the keyboard with an EditText for the user to enter a value. The problem is the View is being partially overlapped by the keyboard, covering up the bottom of the bottom sheet.

    3. Most common Solution
    4. Just reposting @jblejder from this question Keyboard hides BottomSheetDialogFragment since it worked for me, to make it easier for others to find:

      The most convenient way that I found to change this is by creating style:

      <style name="DialogStyle" parent="Theme.Design.Light.BottomSheetDialog">
          <item name="android:windowIsFloating">false</item>
          <item name="android:statusBarColor">@android:color/transparent</item>
          <item name="android:windowSoftInputMode">adjustResize</item>
      </style>
      

      And set this in onCreate method of your BottomSheetDialogFragment:

      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogStyle)
      }
      

      This is how it looks on my device:

      enter image description here

      ==== UPDATE ====

      As already mentioned in the Comments a few times, you might also need to set the state of the BottomSheetDialog to STATE_EXPANDED like in Nordknight's answer below

      dialog = new BottomSheetDialog(getContext(), R.style.BottomSheetDialog);  
      dialog.setOnShowListener(new DialogInterface.OnShowListener() {
      @Override
      public void onShow(DialogInterface dialog) {
                  new Handler().postDelayed(new Runnable() {
                      @Override
                      public void run() {
                          BottomSheetDialog d = (BottomSheetDialog) dialog;
                          FrameLayout bottomSheet = d.findViewById(R.id.design_bottom_sheet);
                          BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
                          bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                      }
                  },0);
              }
          });
      

    5. Solution 2
    6. This might be a redundant answer. Although just pointing out the issue. If you're using BottomSheetDialogFragment, the only way is to enable the attribute android:windowIsFloating to true. This will enable the whole window to be on top of whatever is trying to take the space behind it.

      <style name="BottomSheetDialogThemeNoFloating" parent="Theme.Design.Light.BottomSheetDialog">
              <item name="android:windowIsFloating">false</item>
              <item name="android:windowSoftInputMode">adjustResize|stateVisible</item>
      </style>
      

      Then in your onCreate() of your dialog, set this style.

      override fun onCreate(savedInstanceState: Bundle?) {
              super.onCreate(savedInstanceState)
              // set the window no floating style
              setStyle(DialogFragment.STYLE_NORMAL, R.style.AppRoundedBottomSheetDialogThemeNoFloating)
      }
      

      This is handy for those who frequently use bottom sheets and may want to deal with EditText and soft keyboard overlapping each other.

      Note: The class KeyboardUtil by mikepenz has an issue in which on certain phones, the content view with input field is automatically pushed above keyboard despite giving bottom padding to the whole content view supplied.

    7. Solution 3
    8. dialog = new BottomSheetDialog(getContext(), R.style.BottomSheetDialog);  
      dialog.setOnShowListener(new DialogInterface.OnShowListener() {
      @Override
      public void onShow(DialogInterface dialog) {
                  new Handler().postDelayed(new Runnable() {
                      @Override
                      public void run() {
                          BottomSheetDialog d = (BottomSheetDialog) dialog;
                          FrameLayout bottomSheet = d.findViewById(R.id.design_bottom_sheet);
                          BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
                          bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                      }
                  },0);
              }
          });
      

      This code works fine at Fragment's onCreateView method (thanks for ADM)

    9. Solution 4
    10. Some answers seem to do the trick better than others but will need modification when using the new material design components instead of the older support libraries while also using kotlin

      Hope this will help someone.

      BottomSheetDialog(this, R.style.DialogStyle).apply {
          setContentView(layoutInflater.inflate(R.layout.bottom_sheet, null))
          window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
          findViewById<EditText>(R.id.time_et)?.requestFocus()
      
          show()
      }
      

      layout/bottom_sheet.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:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="#ffffff"
              android:padding="16dp">
      
          <LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical">
      
      
              <LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal">
      
                  <View
                          android:layout_width="0dp"
                          android:layout_height="match_parent"
                          android:layout_weight="1" />
      
                  <LinearLayout
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_weight="5"
                          android:orientation="vertical">
      
                      <TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Time"
                              android:textColor="#000000"
                              android:textSize="24sp"
                              android:textStyle="bold" />
      
                      <LinearLayout
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginTop="8dp"
                              android:orientation="horizontal">
      
                          <EditText
                                  android:id="@+id/time_et"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:inputType="numberSigned"
                                  android:minWidth="50dp"
                                  android:text="15" />
      
                          <TextView
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginLeft="8dp"
                                  android:text="min" />
      
                      </LinearLayout>
      
      
                  </LinearLayout>
      
              </LinearLayout>
      
      
              <Button
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="16dp"
                      android:background="#000"
                      android:text="Save"
                      android:textColor="#fff" />
      
          </LinearLayout>
      
      </ScrollView>
      

      styes.xml (Split for v-21 for using statusBarColor)

          <style name="DialogStyle" parent="Theme.MaterialComponents.Light.BottomSheetDialog">
              <item name="android:windowIsFloating">false</item>
              <item name="android:statusBarColor">@android:color/transparent</item>
              <item name="android:windowSoftInputMode">adjustResize</item>
          </style>
      
    Salvatrix Ngải 2022-08-11
    Android: alternate layout xml for landscape mode

    How can I have one layout for landscape and one for portrait? I want to assume extra width and conserve vertical space when the user rotates the phone over sideways.

    Ganesh Quique 2022-08-16
    android - RelativeLayout is taking fullscreen for wrap_content

    Why does FOOBARZ get layed out all the way at the bottom when no elements are layout_height="fill_parent" in other words, all elements are wrap_content for height? enter image description here

    <?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="wrap_content">
        <TextView
            android:id="@+id/feed_u"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:layout_marginLeft="5dip"
            android:scaleType="centerCrop"
            android:drawableTop="@android:drawable/presence_online"
            android:text="U" />
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/feed_u">
            <ImageView
                android:id="@+id/feed_h"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_minus" />
            <ImageView
                android:id="@+id/feed_ha"
                android:layout_toLeftOf="@id/feed_h"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_plus" />
            <TextView
                android:id="@+id/feed_t"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Title">
            </TextView>
            <TextView
                android:id="@+id/feed_a"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Band"
                android:layout_below="@id/feed_t">
            </TextView>
            <TextView
                android:id="@+id/feed_s"
                android:layout_below="@id/feed_a"
                android:text="S"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content">
            </TextView>
            <TextView
                android:id="@+id/feed_tm"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:text="FOOBARZ"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content">
            </TextView>
    
        </RelativeLayout>
    </RelativeLayout>
    
    Sveinn Erland 2022-08-16
    What is the difference between background, backgroundTint, backgroundTintMode attributes in android layout xml?

    While working with the android layout xml I came across backgroundTint attribute . I don't understand what is for.

    Also what is backgroundTintMode ??

    Urbain Vidar 2022-08-16
    java - Is it possible to use VectorDrawable in Buttons and TextViews using android:DrawableRight?

    When I use VectorDrawable assets in a textview or imageview I get a runtime crash when using "android:DrawableRight" / "android:DrawableEnd" / "android:DrawableStart" / "android:DrawableLeft".

    The app will compile fine without any warnings.

    I am using

    • Gradle 1.5
    • Support Library 23.2 ('com.android.support:appcompat-v7:23.2.0')

    What I have found though is that I can programmatically assign SVG's in Java without crashes like this.

    TextView tv = (TextView) findViewById(R.id.textView);
    tv.setCompoundDrawablesWithIntrinsicBounds(null,null, getResources().getDrawable(R.drawable.ic_accessible_white_36px),null);
    

    (I suspect this is a support library bug for 23.2.)

    But is it possible to use drawableRight etc for SVG assets ?

    Here is my layout

    <?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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="au.com.angryitguy.testsvg.MainActivity">
    
    
    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/ic_accessible_white_36px"
        android:background="@color/colorPrimary"
        android:textColor="#FFFFFF"
        android:textSize="22sp"
        android:text="Hello World!"/>
    </RelativeLayout>
    

    Here is my Activity

    package au.com.angryitguy.testsvg;
    
    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            }
        }
    

    Here is the unmodified VectorDrawable asset from Google's material design site.

    <vector android:height="24dp" android:viewportHeight="24.0"
        android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
        <path android:fillColor="#FFFFFF" android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
        <path android:fillColor="#FFFFFF" android:pathData="M19,13v-2c-1.54,0.02 -3.09,-0.75 -4.07,-1.83l-1.29,-1.43c-0.17,-0.19 -0.38,-0.34 -0.61,-0.45 -0.01,0 -0.01,-0.01 -0.02,-0.01L13,7.28c-0.35,-0.2 -0.75,-0.3 -1.19,-0.26C10.76,7.11 10,8.04 10,9.09L10,15c0,1.1 0.9,2 2,2h5v5h2v-5.5c0,-1.1 -0.9,-2 -2,-2h-3v-3.45c1.29,1.07 3.25,1.94 5,1.95zM12.83,18c-0.41,1.16 -1.52,2 -2.83,2 -1.66,0 -3,-1.34 -3,-3 0,-1.31 0.84,-2.41 2,-2.83L9,12.1c-2.28,0.46 -4,2.48 -4,4.9 0,2.76 2.24,5 5,5 2.42,0 4.44,-1.72 4.9,-4h-2.07z"/>
    </vector>
    

    Here is my app build.gradle

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "au.com.angryitguy.testsvg"
            minSdkVersion 16
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            // Stops the Gradle plugin’s automatic rasterization of vectors
            generatedDensities = []
        }
        // Flag to tell aapt to keep the attribute ids around
        aaptOptions {
            additionalParameters "--no-version-vectors"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.2.0'
    }
    

    Here is the crash. (Note the inflate errors that reference the textview.)

    java.lang.RuntimeException: Unable to start activity ComponentInfo{
        au.com.angryitguy.testsvg/au.com.angryitguy.testsvg.MainActivity}: 
        android.view.InflateException: Binary XML file line #13: 
        Error inflating class TextView
    
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    at android.app.ActivityThread.access$600(ActivityThread.java:130)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    ...
    
    Caused by: android.view.InflateException: 
        Binary XML file line #13: Error inflating class TextView
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
    at au.com.angryitguy.testsvg.MainActivity.onCreate(MainActivity.java:14)
    at android.app.Activity.performCreate(Activity.java:5008)
    ...
    
    Caused by: android.content.res.Resources$NotFoundException: 
        File res/drawable/ic_accessible_white_36px.xml from drawable resource ID #0x7f02004b
    at android.content.res.Resources.loadDrawable(Resources.java:1918)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
    at android.widget.TextView.<init>(TextView.java:622)
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
    at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
    at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:963)
    at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1022)
    at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129) 
    at au.com.angryitguy.testsvg.MainActivity.onCreate(MainActivity.java:14) 
    at android.app.Activity.performCreate(Activity.java:5008) 
    ...
    
    Caused by: org.xmlpull.v1.XmlPullParserException:
        Binary XML file line #1: invalid drawable tag vector
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:877)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:818)
    at android.content.res.Resources.loadDrawable(Resources.java:1915)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
    at android.widget.TextView.<init>(TextView.java:622) 
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60) 
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56) 
    at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103) 
    at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:963) 
    at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1022) 
    at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129) 
    at au.com.angryitguy.testsvg.MainActivity.onCreate(MainActivity.java:14) 
    at android.app.Activity.performCreate(Activity.java:5008) 
    ...
    
    Pāvils Philomena 2022-08-16
    ERROR :rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout

    I am just a beginner to android app development. When i created a new project on Android Studio 1.1.0, it gives up this error "rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout"

    Now i have searched about this on google, and i found possibly 3 solutions given by most of the people.

    They say:

    1. Either change the api (from preview window pane) from 22 to 21, or

    2. Change the App Theme from "Project Theme" to any other theme.

    3. be sure to have imported right appcompat-v7 library in your project structure -> dependencies, Refer these steps: Add the support library feature project identifier to the dependencies section. For example, to include the appcompat project add compile "com.android.support:appcompat-v7:18.0.+" to the dependencies section, as shown in the following example:

    dependencies {
        ...
        compile "com.android.support:appcompat-v7:18.0.+" }
    

    Note: My android support lib is up-to-date (installed it using SDK Manager).

    Following first two steps, removed the error. But I feel that these are not the permanent solutions, the Second step seems just like a temporary workaround. I have doubts about the First step also, that if to remove the error, we change api from 22 to 21, then at the end, our app wont work in Android 5.1.1(API 22), it would be restricted to Android 5.0.1 and below only (API 21). Are my doubts valid? Regarding the third step, is it the permanent solution to this problem?

    P.S : Sorry for mismatching tags, wasn't allowed to add exact tags due to site reputation

    Zaxaria Geirr 2022-08-17
    java - Android Studio layout editor cannot render custom views

    In Android Studio, the layout editor cannot preview custom views in xml.

    Very simple example:

    public class MyCustomView extends FrameLayout {
        public MyCustomView(Context context) {
            super(context);
        }
    
        public MyCustomView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public MyCustomView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    }
    

     

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">
    
        <com.myprojectxxx.view.MyCustomView
            android:layout_width="48dp"
            android:layout_height="48dp" />
    
    </LinearLayout>
    

    Android Studio always says,

    Rendering Problems

    The following classes could not be found:

    • com.myprojectxxx.view.MyCustomView (Fix Build Path, Create Class)

    Tip: Try to build the project

    Of course, I HAVE that class. If I click "Create Class", it complains that the same class already exists. If I rebuild that project, nothing changes.

    And, yes, the project works very well on my Android device. Also, it is rendered very well in Eclipse ADT. However, in Android Studio, it always says that "CLASSES COULD NOT BE FOUND."

    Android Studio does not have the ability to preview a xml file with custom views? What's wrong with this?

    Blodeuwedd Anoushka 2022-08-19
    android - how to change color of textview hyperlink?

    I am using this code for hyperlink:

    <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@+id/hyperlink" 
        android:text="@string/hyperlink"
        android:autoLink="web"/>
    

    By default it is showing blue color, but how do I change color of hyperlink in Android?

    Victor Wenceslaus 2022-08-14
    android - CoordinatorLayout + AppBarLayout + NavigationDrawer

    I have a layouting problem when combining CoordinatorLayout with an AppBarLayout and a NavigationDrawer.

    The problem is, that the NavigationDrawer and it's content are hidden behind the toolbar. I have already did a lot of research and tried a lot of restructuring, but none of the "solutions" fixed my issue.

    A demonstration can be found in this little Webm video: https://www.dropbox.com/s/i5zfc2x2ts2fws7/navigation_drawer_stackoverflow32523188.webm?dl=0

    The base style is Theme.AppCompat.Light.NoActionBar.

    My activity_overview.xml looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/overview_coordinator_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimaryDark"
                app:layout_scrollFlags="enterAlways|scroll" />
    
    
        </android.support.design.widget.AppBarLayout>
    
        <android.support.v4.widget.DrawerLayout
            android:id="@+id/drawer_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clickable="true"
            android:focusableInTouchMode="true">
    
            <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/lorem_ipsum_long" />
            </android.support.v4.widget.NestedScrollView>
    
            <android.support.design.widget.NavigationView
                android:id="@+id/nvView"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:background="@android:color/white"
                app:headerLayout="@layout/nav_header"
                app:menu="@menu/navigationdrawer_main" />
    
        </android.support.v4.widget.DrawerLayout>
    
    
        <android.support.design.widget.FloatingActionButton
            android:id="@+id/overview_floating_action_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
    
            android:clickable="true"
            android:src="@drawable/ic_add"
            app:layout_anchor="@id/overview_coordinator_layout"
            app:layout_anchorGravity="bottom|right|end"
            app:layout_behavior="@string/fab_onscroll_behavior" />
    
    </android.support.design.widget.CoordinatorLayout>
    
    Nandita Maud 2022-08-18
    android - Change color of the drop down arrow of Spinner in XML

    As I wrote in my question, I want to change the color of the drop down arrow (the default arrow, not a custom arrow or something like that) of a Spinner in XML, but the problem is that I couldn't find anything to make reference to it from the XML.

    Is it possible? If yes, how can I change the color?

    Thanks in advance.

    Vitalija Dimas 2022-08-18
    eclipse - Why "Buttons in button bars should be borderless" in Android API Level 15?

    I'm developing an application for Android and I recently changed the API level target from 8 to 15, and now Eclipse is warning me when the Buttons are inside Linear Layouts or Table Rows.

    The same doesn't happen when the Button is in a Relative Layout.

    The warning says:

    Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent)

    I can get rid of the warning by following the suggestion or even by suppressing it, but I'm interested to know why this now? What's wrong with bordered buttons?

    Toni Milford 2022-08-19
    android - How to hide the title bar for an Activity in XML with existing custom theme

    I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can't simply set the theme to @android:style/Theme.NoTitleBar.

    Using the NoTitleBar theme as a parent for my style would remove the title bar from all of my activities.

    Can I set a no title style item somewhere?

    Aled Briana 2022-08-14
    android - Use DataBinding library to set background color resource or null

    I would like to set background color or null on my view using DataBinding library but I get an exception trying to run it.

    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    

    This is how I do it:

    android:background="@{article.sponsored ? @color/sponsored_article_background : null}"
    

    I also tried setting conversion but it didn't work.

    @BindingConversion
    public static ColorDrawable convertColorToDrawable(int color) {
       return new ColorDrawable(color);
    }
    

    Eventually, I resolved it with workaround using @BindingAdapter but I would like to know how to do it properly.

    Filibert Nosizwe 2022-08-19
    android - Own defined Layout , onDraw() method not getting called

    I defined a class like that:

    public class TestMyFrameLayout extends FrameLayout{
    
        Paint mPaint;
        public TestMyFrameLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public TestMyFrameLayout(Context context) {
            super(context);
            mPaint = new Paint();
            mPaint.setColor(Color.GREEN);
        }
    
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawCircle(50f, 50f, 30, mPaint);
        }   
    }
    

    and called it like:

    TestMyFrameLayout myFrameLayout = new TestMyFrameLayout(this);
    LayoutParams myFrameLayoutParams = new LayoutParams(300,300);
    myFrameLayout.setLayoutParams(myFrameLayoutParams);
    setContentView(myFrameLayout);
    

    But In fact TestMyFrameLayout.onDraw(Canvas canvas) function not getting called, why?

    Mallt Agapi 2022-08-17
    Android: how to make a view grow to fill available space?

    This seems straightforward, but I can't figure out how to do it. I have a horizontal layout with an EditText and two ImageButtons. I want the ImageButtons to be of a fixed size, and the EditText to take up the remaining space in the layout. How can this be accomplished?

    <LinearLayout 
            android:orientation="horizontal"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content">
            <EditText 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </EditText>
            <ImageButton 
                android:src="@drawable/img1"
                android:layout_width="50dip" 
                android:layout_height="50dip">
            </ImageButton>
            <ImageButton 
                android:src="@drawable/img2"
                android:layout_width="50dip" 
                android:layout_height="50dip">
            </ImageButton>
    </LinearLayout>
    
    Noah Cas 2022-08-17
    android - How to implement a ViewPager with different Fragments / Layouts

    When I start an activity which implements viewpager, the viewpager created various fragments. I want to use different layouts for each fragment, but the problem is that viewpager shows only two layouts at the max (second layout on all of the remaining fragments after 1).

    Here is the code for SwipeActivity which implements the viewpager :

    public class SwipeActivity extends FragmentActivity
    {
    
        MyPageAdapter pageAdapter;
    
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_swipe);
            pageAdapter = new MyPageAdapter(getSupportFragmentManager());
            ViewPager pager=(ViewPager)findViewById(R.id.pager);
            pager.setAdapter(pageAdapter);
            ActionBar bar = getActionBar();
            bar.setDisplayHomeAsUpEnabled(true);
        }
        /**
        * Custom Page adapter
        */
        private class MyPageAdapter extends FragmentPagerAdapter
        {
            public MyPageAdapter(FragmentManager fm)
            {
                super(fm);
            }
            @Override
            public int getCount()
            {
                return 5;
            }
            @Override
            public Fragment getItem(int position)
            {
                switch(position)
                {
                    case 0: return new MyFragment();
                    case 1: return SecondFragment.newInstance("asdasd");
                    default : return RamFragment.newInstance("s");
                }
            }
         }
    }
    

    Here is the code for the fragments

    public class MyFragment extends Fragment
    {
       @Override
       public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup,    Bundle paramBundle)
       {
         return paramLayoutInflater.inflate(R.layout.processorlayout, paramViewGroup, false);
       }
    }
    

    I used 5 fragments like this, all having different layouts, but the viewpager shows only 2 at the max.

    EDIT : code for SecondFragment

    public class SecondFragment extends Fragment
    {
       public static final String EXTRA_MESSAGE = "EXTRA_MESSAGE";
    
      public static final SecondFragment newInstance(String paramString)
      {
        SecondFragment f = new SecondFragment();
        Bundle localBundle = new Bundle(1);
        localBundle.putString("EXTRA_MESSAGE", paramString);
        f.setArguments(localBundle);
        return f;
      }
    
      @Override
      public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
      {
         return paramLayoutInflater.inflate(R.layout.motherboardlayout, paramViewGroup, false);
      }
    }
    
    Bóthildr Vilma 2022-08-15
    android - getView returning null when fragment has been created from an activity

    I have a working tablet application which I am now trying to make work on phones too. On a table there is two fragments on the screen a list fragment and a details fragment. When on a phone the list fragment appears and creates a new activity when a list item is pressed. This activity simply creates the fragment in the onCreate() method and commits it to the screen as follows.

    // Place an DeallDetailsFragment as our content pane
    DealDetailsFragment f = new DealDetailsFragment();
    getFragmentManager().beginTransaction().add(android.R.id.content, f).commit();
    getFragmentManager().executePendingTransactions();
    

    This is working as expected however from within this activity I need to tell the fragment what details to load and display. In my DealDetailsFragment class I have a updateDeal() method which updates the content as follows.

    if (deal==null) { // could be null if user presses the loading deals list item before it loads
        return;
    }
    this.deal=deal;
    if (dealTitle==null) { // get the view objects only once
        holder = new ViewHolder();  
        holder.dealHeat=(TextView) getView().findViewById(R.id.dealDetails_heat_textView);
        holder.dealPrice=(TextView) getView().findViewById(R.id.dealDetails_price_textView);
        holder.dealRetailer=(TextView) getView().findViewById(R.id.dealDetails_retailer_textView);
        holder.dealTitle=(TextView) getView().findViewById(R.id.dealDetails_title_textView);
        holder.dealDesc=(TextView) getView().findViewById(R.id.dealDetails_desc_textView);
        holder.goToButton= (LinearLayout) getView().findViewById(R.id.dealDetails_goToDeal);
        holder.dealImage=(ImageView) getView().findViewById(R.id.dealDetails_imageView);
        holder.postedBy=(TextView) getView().findViewById(R.id.dealDetails_poster_textView);
        holder.datePosted=(TextView) getView().findViewById(R.id.dealDetails_date_textView);
    

    getView() is returning null when the application is ran on a phone where there is only a single fragment shown.

    Any ideas? Unfortunately, there is not many fragment examples available online.

    Lenuța Robert 2022-08-19
    How do I create a ListView with rounded corners in Android?

    How do I create a ListView with rounded corners in Android?

    Fabian Mirela 2022-08-15
    android - ConstraintLayout, when constraint dependent view is gone, the layout view behave weirdly

    I'm using ConstraintLayout where I will show as below

    enter image description here

    I would like to hide First (using gone), and which the view I expect to be as below (where ElasticBody will stretch over to use up the original First view space as well.

    enter image description here

    However, when I actual set First to gone, my view turn out to be as below (all image as from Android Studio Design view). My Elastic Body is missing as well, and the height expanded weirdly.

    enter image description here

    My layout code as below

    <android.support.constraint.ConstraintLayout 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="wrap_content"
        android:padding="16dp">
    
        <TextView
            android:id="@+id/txt_first"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#0ff"
            android:text="First"
            android:visibility="gone"
            android:textSize="26sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/txt_body"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <TextView
            android:id="@+id/txt_body"
            android:layout_width="0dp"
            android:background="#f0f"
            android:layout_height="wrap_content"
            android:text="Elastic Body"
            android:textSize="26sp"
    
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/txt_tail"
            app:layout_constraintStart_toEndOf="@+id/txt_first"
            app:layout_constraintTop_toTopOf="parent" />
    
        <TextView
            android:id="@+id/txt_tail"
            android:background="#ff0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Tail"
            android:textSize="26sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/txt_body"
            app:layout_constraintTop_toTopOf="parent" />
    
    </android.support.constraint.ConstraintLayout>
    

    (Note, if you remove the gone, you'll get the first image view). Why is this so? How could I fix it where when my First is gone, I could the Elastic Body stretch out correctly?

    p/s: I know how to do it in LinearLayout and RelativeLayout... but wonder if this is a limitation on ConstraintLayout?

    Rupa Luned 2022-08-19
    android - How to get RelativeLayout working with merge and include?

    I have been trying for a few days now to make my layouts more efficient by converting from using several levels of nested LinearLayouts to one RelativeLayout and have come across a few problems that I haven not been able to find a workaround for...

    I have searched the Android beginners group and this site and have not been able to find anything that would help me solve the problem.

    I read on one of the blogs that you can combine layouts with merge and include tags. So what I have is a main layout file with a RelativeLayout root element. Inside of that I have 5 include tags that reference 5 different xml layout files that each have a merge element for the root (all of my merge files are the same except for the ids in them).

    I am running into two problems, which I will explain after posting a simplified version of my layout code:

    Sample Main Layout File:

    <?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"
        android:background="@drawable/translucent_gray" >
    
        <include 
            android:id="@+id/running_gallery_layout_id"
            layout="@layout/running_gallery_layout" />
    
        <include 
            android:id="@+id/recent_gallery_layout_id" 
            layout="@layout/recent_gallery_layout"
            android:layout_below="@id/running_gallery_layout_id" />
    
        <include
            android:id="@+id/service_gallery_layout_id"
            layout="@layout/service_gallery_layout"
            android:layout_below="@id/recent_gallery_layout_id" />
    
        <include
            android:id="@+id/process_gallery_layout_id"
            layout="@layout/process_gallery_layout"
            android:layout_below="@id/service_gallery_layout_id" />
    
    </RelativeLayout>
    

    Sample included merge file:

    <?xml version="1.0" encoding="utf-8"?>
    <merge xmlns:android="http://schemas.android.com/apk/res/android">
        <TextView 
            style="@style/TitleText"
            android:id="@+id/service_gallery_title_text_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:text="@string/service_title" />
    
        <Gallery
            android:id="@+id/service_gallery_id"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_below="@id/service_gallery_title_text_id" />
    
        <TextView 
            style="@style/SubTitleText"
            android:id="@+id/service_gallery_current_text_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/service_gallery_title_text_id"
            android:layout_above="@id/service_gallery_id" />
    </merge>
    

    I am running into two problems:

    1) The android:layout_* attributes seem to be ignored when used in the include tag and all of the merged layouts are displayed on top of each other. According to this post (http://developer.android.com/resources/articles/layout-tricks-reuse.html) "any android:layout_* attribute can be used with the <include /> tag"

    2) Since I couldn't get this working I decided to try adding an android:layout_below attribute to the first TextView item in each merge layout file, meaning that each merge file would be referencing an id from another merge layout file... For the most part this actually worked and my layout looks fine. However, I get an error on one of the android:layout_below attributes saying that it can't find the id I specified... I have double and triple checked the ids to make sure they were correct. The weirdest part is that I used the AutoFill feature to put the id in the attribute in the first place.

    If anyone has any suggestions or workarounds I will be more than happy to try them out. Also, if anyone can think of a way for me to just have one merge xml layout file instead of 5 that would be greatly appreciated. I couldn't find a way to do that because I need to have access to each item in the merge layout files at runtime...

    Konrad Adrianna 2022-08-16
    android - How to add different weight to ConstraintLayout views

    In my layout, I have a ConstraintLayout containing two TextView elements. They are currently the same size, but I would like them to have different weights with a 6:4 ratio.

    How can this be achieved in my ConstraintLayout?

    Vitalija Dimas 2022-08-18
    Android Keyboard hides EditText

    When I try to write something in an EditText which is at the bottom of the screen, the soft keyboard hides the EditText. How can I resolve this issue? Below is my xml code. I'm using this in a Fragment.

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
    
    
            <LinearLayout
                android:id="@+id/linearLayoutTopDetails"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/linearLayoutTop"
                android:layout_marginLeft="6dp"
                android:layout_marginRight="6dp"
                android:layout_marginTop="6dp"
                android:orientation="vertical" >
    
                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/list_design1"
                    android:orientation="vertical" >
    
                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="80dp"
                        android:layout_weight="100"
                        android:orientation="horizontal" >
    
                        <ImageView
                            android:id="@+id/ImageViewProfImagePostDetail"
                            android:layout_width="0dp"
                            android:layout_height="fill_parent"
                            android:layout_marginTop="2dp"
                            android:layout_weight="24.84"
                            android:paddingLeft="5dp"
                            android:paddingRight="5dp"
                            android:paddingTop="5dp" />
    
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="60"
                            android:orientation="vertical" >
    
                            <TextView
                                android:id="@+id/textViewNamePostDetail"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Robin"
                                android:textSize="17sp" />
    
                            <TextView
                                android:id="@+id/textViewLocationPostDetail"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="1dp"
                                android:drawableLeft="@drawable/location"
                                android:text="beijing, China" />
    
                            <TextView
                                android:id="@+id/textViewTimeAgoPostDetail"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text=" 18min ago" />
                        </LinearLayout>
    
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_height="fill_parent"
                            android:layout_weight="15"
                            android:orientation="horizontal" >
    
                            <TextView
                                android:id="@+id/textViewReportAbusePostDetail"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="@drawable/flag"
                                android:paddingLeft="5dp" />
    
                            <TextView
                                android:id="@+id/textViewDeletePostDetail"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginLeft="15dp"
                                android:background="@drawable/delete"
                                android:visibility="gone" />
                        </LinearLayout>
                    </LinearLayout>
    
                    <TextView
                        android:id="@+id/textViewDescriptionPostDetail"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:layout_marginTop="2dp"
                        android:singleLine="false"
                        android:text="Description or caption of the post"
                        android:textSize="17sp" />
                </LinearLayout>
    
                <ImageView
                    android:id="@+id/feedPostedImagePostDetail"
                    android:layout_width="fill_parent"
                    android:layout_height="200dp"
                    android:layout_marginTop="5dp"
                    android:scaleType="fitCenter"
                    android:visibility="gone" />
    
                <LinearLayout
                    android:id="@+id/linearLayoutOptions"
                    android:layout_width="fill_parent"
                    android:layout_height="33dp"
                    android:layout_marginTop="2dp"
                    android:layout_weight="100"
                    android:background="@drawable/bar"
                    android:orientation="horizontal" >
    
                    <TextView
                        android:id="@+id/textViewShakePostDetail"
                        android:layout_width="0dp"
                        android:layout_height="fill_parent"
                        android:layout_marginLeft="15dp"
                        android:layout_weight="25"
                        android:drawableLeft="@drawable/like"
                        android:gravity="center"
                        android:singleLine="true"
                        android:text="Shake"
                        android:textSize="12sp" />
    
                    <TextView
                        android:id="@+id/textViewCommentPostDetail"
                        android:layout_width="0dp"
                        android:layout_height="fill_parent"
                        android:layout_weight="41"
                        android:drawableLeft="@drawable/comment"
                        android:gravity="center"
                        android:paddingLeft="20dp"
                        android:text="Comment" />
    
                    <TextView
                        android:id="@+id/textViewSharePostDetail"
                        android:layout_width="0dp"
                        android:layout_height="fill_parent"
                        android:layout_weight="33"
                        android:drawableLeft="@drawable/share"
                        android:gravity="center"
                        android:paddingLeft="20dp"
                        android:text="Spread" />
                </LinearLayout>
            </LinearLayout>
    
            <ListView
                android:id="@+id/listViewFeedsDetail1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/linearLayoutTopDetails"
                android:layout_marginBottom="4dp"
                android:layout_marginLeft="6dp"
                android:layout_marginRight="6dp"
                android:layout_marginTop="6dp" >
            </ListView>
    
            <LinearLayout
                android:id="@+id/linearLayoutPostcomment"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/listViewFeedsDetail1"
                android:background="#FFFFFF"
                android:orientation="horizontal"
                android:weightSum="100" >
    
                <EditText
                    android:id="@+id/editTextComment"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="80" />
    
                <Button
                    android:id="@+id/buttonPostComment"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="20"
                    android:background="#F0F8FF"
                    android:text="Post" >
                </Button>
            </LinearLayout>
        </RelativeLayout>
    </ScrollView>
    

    I have tried to resolve this issue by adding changes through code but no success.

    Below is the image before and after clicking on the EditText.

    screenshot without soft keyboard, EditText visible

    screenshot with soft keyboard, EditText hidden

    Ganesh Quique 2022-08-19
    android - What does postInvalidate() do?

    What is the use of the postInvalidate() function in Android? I have been seeing this function in a lot of places. When I Googled, I came out with this much:

    postInvalidate-- post an invalidate request on the UI-thread

    I don't know what the phrase "invalidate request" there means. Can someone explain in detail what is happening here?

    Furqan Terzo 2022-08-19
    Write a file in external storage in Android

    I want to create a file in external storage sdCard and write to it.I have searched through internet and try but not getting the result,I have added permission in Android Manifest file as well,I am doing this on Emulator,I am trying the following code and getting a ERRR", "Could not create file".

    btnWriteSDFile = (Button) findViewById(R.id.btnWriteSDFile);
    btnWriteSDFile.setOnClickListener(new OnClickListener() {
        //private Throwable e;
    
        @Override
        public void onClick(View v) {
            // write on SD card file data from the text box
            try {
                File myFile = new File("/sdcard/mysdfile.txt");
                myFile.createNewFile();
                FileOutputStream fOut = new FileOutputStream(myFile);
                OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
                myOutWriter.append(txtData.getText());
                myOutWriter.close();
                fOut.close();
    
            } catch (Exception e) {
                  Log.e("ERRR", "Could not create file",e);
            } 
        }// onClick
    }); // btnWriteSDFile
    
    Noah Cas 2022-08-18
    Android: show/hide a view using an animation

    I've been looking through many google results / questions on here to determine how to show/hide a view via a vertical animation, but I can't seem to find one that's exactly right or not too vague.

    I have a layout (undo bar) that's below another layout and above multiple other widgets; this undo bar should vertically slide open and slide closed, depending on the circumstances.

    Currently all I do right now is set the view to be visible or gone.

    Emmy Kanani 2022-08-17
    Android-L CardView Visual Touch Feedback

    could anybody explain to me how to implement some of the visual touch feedback that was demonstrated at Google I/O 2014 within a CardView.

    Here is how I am using the CardView in XML, there is probably something small that I am missing, so I just wondered if anyone could help me?.

    <!-- A CardView -->
    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/CardView_1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp" 
        card_view:cardCornerRadius="4dp"
        android:elevation="2dp">
    
        <LinearLayout
            android:id="@+id/LinearLayout_1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:onClick="RunSomeMethod"">
    
        <!-- Main CardView Content In Here-->
    
        </LinearLayout> </android.support.v7.widget.CardView>
    
    Gert Branimira 2022-08-18
    android - How do I align views at the bottom of the screen?

    Here's my layout code;

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <TextView android:text="@string/welcome"
            android:id="@+id/TextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </TextView>
    
        <LinearLayout android:id="@+id/LinearLayout"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="bottom">
    
                <EditText android:id="@+id/EditText"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content">
                </EditText>
    
                <Button android:text="@string/label_submit_button"
                    android:id="@+id/Button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                </Button>
    
        </LinearLayout>
    
    </LinearLayout>
    

    What this looks like is on the left and what I want it to look like is on the right.

    Android Layout - Actual (Left) and Desired (Right)

    The obvious answer is to set the TextView to fill_parent on height, but this causes no room to be left for the button or entry field.

    Essentially the issue is that I want the submit button and the text entry to be a fixed height at the bottom and the text view to fill the rest of the space. Similarly, in the horizontal linear layout I want the submit button to wrap its content and for the text entry to fill the rest of the space.

    If the first item in a linear layout is told to fill_parent it does exactly that, leaving no room for other items. How do I get an item which is first in a linear layout to fill all space apart from the minimum required by the rest of the items in the layout?


    Relative layouts were indeed the answer:

        <?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">
    
        <TextView
            android:text="@string/welcome"
            android:id="@+id/TextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true">
        </TextView>
    
        <RelativeLayout
            android:id="@+id/InnerRelativeLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" >
    
            <Button
                android:text="@string/label_submit_button"
                android:id="@+id/Button"
                android:layout_alignParentRight="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </Button>
    
            <EditText
                android:id="@+id/EditText"
                android:layout_width="fill_parent"
                android:layout_toLeftOf="@id/Button"
                android:layout_height="wrap_content">
            </EditText>
    
        </RelativeLayout>
    
    </RelativeLayout>
    
    Orion Waman 2022-08-14
    android - ImageView not keeping max height and width

    I load an image into an ImageView using .setImageURI(selectedImageUri) that is retrieved from the user's photo gallery. I have the image view restrict the size with

    android:maxHeight="150dp"
    android:minHeight="150dp" 
    android:maxWidth="150dp" 
    android:minWidth="150dp"
    

    It's fine up until the you add the image from the gallery. The image then forgets about the max height and width. It is as wide as the display and there is a lot of space above and below the image. I had to add a scrollview just to see the image and scroll down. there is an even amount of space above and below. Has anyone run into this problem before?

    Marianne Alf 2022-08-21
    android - Cursor adapter and sqlite example

    Hello I am looking for sample code in which cursor adapter is used with sqlite?

    Elise Pankaj 2022-08-19
    android - Authorative way to override onMeasure()?

    What's the correct way of overriding onMeasure()? I've seen various approaches. For example, Professional Android Development uses MeasureSpec to calculate the dimensions, then ends with a call to setMeasuredDimension(). For example:

    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
    int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
    int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
    this.setMeasuredDimension(parentWidth/2, parentHeight);
    }
    

    On the other hand, as per this post, the "correct" way is to use MeasureSpec, call setMeasuredDimensions(), followed by a call to setLayoutParams(), and ending with a call to super.onMeasure(). For example:

    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
    int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
    int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
    this.setMeasuredDimension(parentWidth/2, parentHeight);
    this.setLayoutParams(new *ParentLayoutType*.LayoutParams(parentWidth/2,parentHeight));
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
    

    So which is the right way? Neither approach has worked 100% for me.

    I guess really what I'm asking is does anyone know of a tutorial that explains onMeasure(), layout, dimensions of child views etc.?

    Greta Iris 2022-08-17
    android - What is the difference between px, dip, dp, and sp?

    What is the difference between the units of measure px, dip, dp, and sp?

    Pétur Gulnara 2022-08-12