How to make edittext size included? Android

I know an attribute that forces the text "disapear" on the left side of the Edittext to support one line (singleLine = "true"). But my problem is when I fill in the edittext before the view is displayed ... in this case my edittexts all exit the screen ... have any ideas? THX!

This is what happens when filling out an empty Edittext. Everything remains placed, and the text disappears on the left side.

Screenshot

and when I pre-populate my DB

Screenshot

here is the edittext code:

<EditText android:id="@+id/InscripChampNom"
android:layout_height="wrap_content" android:textSize="14px"
android:inputType="textPersonName" android:layout_marginRight="20dip"
android:singleLine="true" android:textColor="@color/background"></EditText>

The Layout table is defined as follows:

<TableLayout android:layout_width="fill_parent"
android:stretchColumns="1" android:layout_height="fill_parent">

I also tried with attribute

android:layout_width="fill_parent"

and

android:layout_width="wrap_content"

no success at all ...

Perhaps there is a conflict between the input type and the single line?

EDIT Here is the complete code for my problem:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical" android:background="@color/backgroundzen"
android:layout_gravity="fill" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:paddingLeft="6dip"
android:paddingRight="6dip">
<TableLayout style="@style/LayoutWhiteBgrdFillWrap"
    android:paddingLeft="6dip" android:paddingRight="6dip"
    android:stretchColumns="1">
    <TextView android:id="@+id/NomFormationConference" style="@style/textViewTitleRedzenBold"
        android:text="Nom conférence"></TextView>
    <TableRow android:layout_margin="2dip">
        <TextView android:id="@+id/DateSession" android:textColor="@color/textezenrouge"
            android:layout_height="wrap_content" android:layout_width="wrap_content"
            android:text="date début"></TextView>
        <TextView android:id="@+id/speakerConf" android:textColor="@color/textezenrouge"
            android:layout_height="wrap_content" android:layout_width="wrap_content"
            android:text="speaker"></TextView>
    </TableRow>
    <TableRow android:layout_margin="2dip">
        <TextView android:id="@+id/InscripNom" android:layout_width="wrap_content"
            android:textColor="@color/background" android:layout_height="wrap_content"
            android:text="@string/nom" android:textStyle="bold"></TextView>
        <EditText android:id="@+id/InscripChampNom"
            android:layout_height="wrap_content" android:textSize="14sp"
            android:layout_width="fill_parent" android:inputType="textPersonName"
            android:layout_marginRight="20dip" android:hint="@string/nomh"
            android:singleLine="true" android:textColor="@color/background"></EditText>
    </TableRow>

// The last pill is repeated 5 times with different data inside.      

:

<style name="LayoutWhiteBgrdFillWrap">
    <item name="android:background">@color/backgroundzen</item>
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">fill_parent</item>
</style>

EditText:

misc = SQLiteDatabase.openDatabase("/data/data/com.mobile.zen/databases/" + Constants.UNVERSIONNED_DATABASE, null,
            SQLiteDatabase.OPEN_READONLY);
    Cursor c = misc.query("MISC", null, null, null, null, null, null);
    if (c.moveToFirst()) {
        do {
            nomInscrit.setText(c.getString(1));
        } while (c.moveToNext());
    }
    c.close();
    misc.close();
+3
6

android:shrinkColumns="1" TableLayout, , EditText , .

+5

android:layout_width EditText. , (, RelativeLayout, android:layout_alignParentRight="true").

0

, .

:

<?xml version="1.0" encoding="utf-8"?>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:stretchColumns="1"
    android:layout_height="fill_parent">

    <EditText android:id="@+id/a" android:layout_height="wrap_content"
        android:textSize="14px" android:inputType="textPersonName"
        android:layout_marginRight="20dip" android:singleLine="true"
        android:textColor="@android:color/black"></EditText>

    <EditText android:id="@+id/b" android:layout_height="wrap_content"
        android:textSize="14px" android:inputType="textPersonName"
        android:layout_marginRight="20dip" android:singleLine="true"
        android:textColor="@android:color/black"></EditText>

    <EditText android:id="@+id/c" android:layout_height="wrap_content"
        android:textSize="14px" android:inputType="textPersonName"
        android:layout_marginRight="20dip" android:singleLine="true"
        android:textColor="@android:color/black"></EditText>

</TableLayout>
0

, Android. " "

Android: stretchColumns = "1"

   <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical" android:background="#ffffff"
android:layout_gravity="fill" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:paddingLeft="6dip">
  <TableLayout android:layout_below="@+id/reltable1" android:id="@+id/tablelayout_main" android:layout_width="fill_parent" android:layout_marginRight="10dip" android:layout_marginBottom="10dip" android:layout_height="fill_parent" android:layout_centerInParent="true" android:gravity="center" android:stretchColumns="1">
    <TextView android:id="@+id/NomFormationConference" 
        android:text="Nom conférence"></TextView>
    <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent">
        <TextView android:id="@+id/DateSession"
            android:layout_height="wrap_content" android:layout_width="wrap_content"
            android:text="date début"></TextView>
        <TextView android:id="@+id/speakerConf" 
            android:layout_height="wrap_content" android:layout_width="wrap_content"
            android:text="speaker"></TextView>
    </TableRow>
      <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent">
        <TextView android:id="@+id/InscripNom" android:layout_width="wrap_content"
           android:layout_height="wrap_content"
            android:text="nom" android:textStyle="bold"></TextView>
        <EditText android:id="@+id/InscripChampNom"
            android:textSize="14sp"
            android:inputType="textPersonName"
            android:hint="nomh" android:text="dsfdsfdsfsdfsdfsssssssssssssssssssssssssssssss" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:layout_width="220dip" android:ellipsize="end"></EditText>
    </TableRow>
</TableLayout>
</ScrollView>

I also added the height and width property for TableRow

0
source

I don't think tablelayout works in scrollview. I had the setting as such, and it did not produce errors, but the emulator simply does not load the application and says that it stops working. I removed scrollview and started working.

I think the problem is that tablelayout has its own scrollbars, it doesn't need scrollview and maybe two conflicts.

0
source
<EditText 
    android:id="@+id/InscripChampNom"
    android:layout_height="wrap_content" 
    android:textSize="14px" 
    android:inputType="none" 
    android:layout_marginRight="20dip" 
    android:singleLine="true" 
    android:textColor="@color/background" 
    android:editable="false"
    android:ellipsize="end">
</EditText>
0
source

Source: https://habr.com/ru/post/1693966/


All Articles