logo
down
shadow

Android: Layout increase width of textview


Android: Layout increase width of textview

By : wqqdzy
Date : November 17 2020, 04:28 AM
may help you . I want to increase the width of TextView and for that I tried layout_weight but it didn't do the trick. Please see below screenshot: , It is the LinearLayout's layout_weight you need to change.
code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="@dimen/five_dp"
    android:layout_marginTop="@dimen/five_dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/listItemContactIconChats"
        android:layout_width="48dip"
        android:layout_height="48dip"
        android:layout_marginBottom="@dimen/five_dp"
        android:layout_marginTop="@dimen/five_dp" />

    <LinearLayout
        android:layout_width="0dp" // Changed
        android:layout_weight="1" // Changed
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/five_dp"
        android:layout_marginTop="@dimen/five_dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/listItemContactNameChats"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="@dimen/five_dp"
            android:layout_marginTop="3dp"
            android:textSize="@dimen/sixteen_sp" />

        <TextView
            android:id="@+id/listItemLastMessageChats"
            android:layout_width="fill_parent"
            android:layout_height="0dp" 
            android:layout_weight="1"
            android:layout_gravity="bottom"
            android:layout_marginLeft="@dimen/five_dp"
            android:layout_marginTop="@dimen/five_dp"
            android:gravity="bottom"
            android:textColor="@color/chat_title_gray"
            android:textSize="@dimen/twelve_sp" />
    </LinearLayout>

    <TextView
        android:id="@+id/listItemLastTimeChats"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_marginRight="@dimen/five_dp"
        android:layout_marginTop="@dimen/ten_dp"
        android:gravity="right"
        android:textColor="@color/chat_title_gray"
        android:textSize="@dimen/twelve_sp" />

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="@dimen/five_dp"
    android:layout_marginTop="@dimen/five_dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/listItemContactIconChats"
        android:layout_width="48dip"
        android:layout_height="48dip"
        android:layout_marginBottom="@dimen/five_dp"
        android:layout_marginTop="@dimen/five_dp" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/five_dp"
        android:layout_marginTop="@dimen/five_dp"
        android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/listItemContactNameChats"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="@dimen/five_dp"
            android:layout_marginTop="3dp"
            android:textSize="@dimen/sixteen_sp" />


        <TextView
            android:id="@+id/listItemLastTimeChats"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:layout_marginRight="@dimen/five_dp"
            android:layout_marginTop="@dimen/ten_dp"
            android:gravity="right"
            android:textColor="@color/chat_title_gray"
            android:textSize="@dimen/twelve_sp" />

        </LinearLayout>


        <TextView
            android:id="@+id/listItemLastMessageChats"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_gravity="bottom"
            android:layout_marginLeft="@dimen/five_dp"
            android:layout_marginTop="@dimen/five_dp"
            android:layout_weight="1"
            android:gravity="bottom"
            android:textColor="@color/chat_title_gray"
            android:textSize="@dimen/twelve_sp" />
    </LinearLayout>

</LinearLayout>


Share : facebook icon twitter icon
android : after drag textview by called layout(), setTextView() will revert TextView to Original Position

android : after drag textview by called layout(), setTextView() will revert TextView to Original Position


By : Andre Gm
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Definitely it will go to the original position because it's always there from its parent's view point. You only call CustomView.layout to layout the child but its parent doesn't know that. So you'll have to use another approach to fix this. Try calling View.setX/setY so that the ViewParent knows (and could handle) the translation.
Unable to increase border width of characters on textview

Unable to increase border width of characters on textview


By : Lâm Nguyễn
Date : March 29 2020, 07:55 AM
Does that help You can download the font type and add it to the items you need
code :
    TextView myTextView = (TextView) findViewById(R.id.textView);
    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/yourfont.ttf");
    myTextView.setTypeface(typeface);
TextView Layout width Change

TextView Layout width Change


By : Faith Karimi
Date : March 29 2020, 07:55 AM
Hope that helps After getting your TextView in your code :
tv.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Android layout how to horizontal align textView with dynamical width

Android layout how to horizontal align textView with dynamical width


By : Kasoma
Date : March 29 2020, 07:55 AM
it helps some times I'm not sure if this meets your requirements, but this is my attempt using ConstraintLayout
code :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="match_parent"
    android:padding="16dp">

    <TextView
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#eee"
        android:ellipsize="end"
        android:maxLines="1"
        android:text="something very very very very very long"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@id/two"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="fixed"
        app:layout_constraintBaseline_toBaselineOf="@id/one"
        app:layout_constraintLeft_toRightOf="@id/one"
        app:layout_constraintRight_toLeftOf="@id/three"/>

    <TextView
        android:id="@+id/three"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="#eee"
        android:ellipsize="end"
        android:maxLines="1"
        android:text="this is pretty short"
        app:layout_constraintBaseline_toBaselineOf="@id/one"
        app:layout_constraintLeft_toRightOf="@id/two"
        app:layout_constraintRight_toLeftOf="@id/four"
        app:layout_constraintWidth_default="wrap"/>

    <TextView
        android:id="@+id/four"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="fixed"
        app:layout_constraintBaseline_toBaselineOf="@id/one"
        app:layout_constraintLeft_toRightOf="@id/three"
        app:layout_constraintRight_toRightOf="parent"/>


</androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintWidth_max="256dp"
Android: Radius of Circle in TextView Always Fixed by TextView Width and Height

Android: Radius of Circle in TextView Always Fixed by TextView Width and Height


By : Chandru
Date : March 29 2020, 07:55 AM
I wish did fix the issue. With the standard Android widgets it's seems to be impossible, due you are drawing a "oval" around the component.
An oval could become a circle as a circle is an specialization where height is equal to width. My advice is to reimplement the way of component size is computed. Just square the layout always by overriding onMeasure (here is the more simple way to do, please click on the link in the bottom):
Related Posts Related Posts :
  • Passing variables from one activity to another
  • Create Multicolored Pie Chart in Android Studio
  • how to kill progress dialog in android
  • Show Error on the tip of the Edit Text Android
  • How do I use getWindowManager() by another java file
  • fetching images from gallery on android phones with internal storage
  • How to discover devices like Google TV and Nexus-Q using MediaRoute API on Android?
  • "Unfortunately your app stopped working"- Facebook Integration for Android
  • How to animate button in android?
  • Resource Not Found Exception in class without context or activity
  • Launching Android Netflix App And Passing Video Id
  • Making a Phone Call with a Number Extension
  • NullPointerException at BoringLayout.isBoring is anything but boring
  • java.lang.RuntimeException: Unable to get provider
  • Testing custom Views with Robolectric
  • tools:listheader doesn't work although tools:listitem does
  • oppo, vivo app kill notification not coming in android fcm
  • OnClick Method could not function correctly with if else statement
  • Best method to download image from url in Android
  • How can I open Drawer Layout moving all the view and not just slide over?
  • how to show profile pictures of friends in a list view?
  • Creating TimePickerDialog with custom style in Android
  • Android 2.3.6 support library v7 option menu is missing
  • need of vblank in Display subssytem
  • Android MP4 stream - Video cannot be played
  • FastAdapter: Undo button does not show up after swipe
  • What are reasons to pass getActivity as the LifecycleOwner to the LiveData's observe method in a fragment?
  • Implement Face Recognition in Android
  • Titanium studio cannot run "titanium" command in terminal
  • How to execute command line ffmpeg commands programatically in android?
  • Make Android List Items clickable with each item pointing to a different link
  • listview runs successfully, but nothing is display in emulator
  • How to zoom in a bitmap with high resolution?
  • Passing listView data through intent
  • Google map route direction show by arrows in android v2
  • how to start "uiautomator test run" from android code?
  • Proguard in Android Library
  • Alarm Clock from GIT - Gives error - Android
  • Mock injection using Mockito - Android
  • Get Bitmap from universal image loader
  • Unable to include custom font in android
  • Basics on using logcat in Android development
  • Android: Clear cache programmatically
  • Android: pass object without serialization
  • Can not scroll and click item on gridview inside scrollview
  • Android device keeps disconnecting from adb / eclipse
  • Volley cannot create cache directory. Could not clean up file
  • ShareActionProvider icon in actionbar
  • How to open a custom attachment using an Android app?
  • Unable to add column dynamically into the sqlite table
  • android persistence activity which never stop
  • The Google Play services resources were not found. Check your project configuration to ensure that the resources are inc
  • How to select files from google drive in android?
  • Run a AsyncTask every 10 seconds until cancelled
  • Blur on touch. Android application
  • NDK Android - Can't build ARMv5 and V7 at the same time
  • Android development with Eclipse clean and build
  • How to set Different Key Background for every Key in Android Custom Keyboard
  • Face recognition using OpenCV in android?
  • Tumblr API - Jumblr for Android [OAuthConnectionException]
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org