I have two TextView. First TextView contains dynamic text, that can be small and big. Second TextView contains static small text. Second TextView should be located to right of f
You can add a LinearLayout with orientation: "horizontal" and add both textviews in it.
<LinearLayout
...
android:orientation="horizontal">
<TextView .../>
<TextView .../>
</LinearLayout>
try this code I think It will work as you want
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/txt_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="asdasdadasdasdasdasdasdasdasdasdasdasdasdasd"/>
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:text="2asdasdadasdasdasdasdasdasdasdasdasdasdasdasd"
android:layout_height="wrap_content"/>
</LinearLayout>
Try this FlexboxLayout
Add the following dependency to your build.gradle file:
dependencies {
compile 'com.google.android:flexbox:0.3.2'
}
Usage
<com.google.android.flexbox.FlexboxLayout
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"
app:flexWrap="nowrap"
app:alignItems="stretch"
app:alignContent="stretch" >
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff0"
android:text="niledfdfdfhfgfdgdfgdfgfgfggdfgdfggggggggggggggggggggggggggggggggggggggggggggggfhssdsdsdsfgdfgfgfgfgfggfgdgdfgfgfgdsddjfhdkjfhjshdf" />
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:text="nilxcvxceshdfhd"
android:background="@color/colorAccent"
android:layout_height="wrap_content"
app:layout_minWidth="50dp"
app:layout_minHeight="20dp"
app:layout_alignSelf="center"
/>
</com.google.android.flexbox.FlexboxLayout>
OUTPUT
OUTPUT WITH BIG TEXT