Skip to content

Commit c4bfc11

Browse files
committed
Improve the alignment of titleTextView and audioTrackTextView
This fulfills the following: * both should never push content outside of the view * there should be no wasted space * `audioTrackTextView` is always aligned to the right * both should grow equally but also respect their respective contents size first Caveats: * Currently the layout weight is distributed using "NestedWeights" which require a widget to be measured twice. According to Android Studio this might cause an exponential performane impact, however there is currently just a single nested component so the effect should be not noticeable
1 parent c49e444 commit c4bfc11

1 file changed

Lines changed: 66 additions & 51 deletions

File tree

app/src/main/res/layout/player.xml

Lines changed: 66 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -119,64 +119,79 @@
119119
tools:ignore="RtlHardcoded" />
120120

121121
<LinearLayout
122-
android:id="@+id/metadataView"
123122
android:layout_width="0dp"
124-
android:layout_height="wrap_content"
125-
android:layout_marginTop="6dp"
126-
android:layout_marginEnd="8dp"
123+
android:layout_height="match_parent"
127124
android:layout_weight="1"
128-
android:gravity="top"
129-
android:orientation="vertical"
130-
tools:ignore="RtlHardcoded">
125+
android:orientation="horizontal">
131126

132-
<org.schabi.newpipe.views.NewPipeTextView
133-
android:id="@+id/titleTextView"
134-
android:layout_width="match_parent"
127+
<LinearLayout
128+
android:id="@+id/metadataView"
129+
android:layout_width="wrap_content"
135130
android:layout_height="wrap_content"
136-
android:ellipsize="marquee"
137-
android:fadingEdge="horizontal"
138-
android:marqueeRepeatLimit="marquee_forever"
139-
android:scrollHorizontally="true"
140-
android:singleLine="true"
141-
android:textColor="@android:color/white"
142-
android:textSize="15sp"
143-
android:textStyle="bold"
144-
tools:ignore="RtlHardcoded"
145-
tools:text="The Video Title LONG very LONG" />
131+
android:layout_marginTop="6dp"
132+
android:layout_marginEnd="8dp"
133+
android:layout_weight="1"
134+
android:gravity="top"
135+
android:orientation="vertical"
136+
tools:ignore="NestedWeights,RtlHardcoded">
137+
138+
<org.schabi.newpipe.views.NewPipeTextView
139+
android:id="@+id/titleTextView"
140+
android:layout_width="match_parent"
141+
android:layout_height="wrap_content"
142+
android:ellipsize="marquee"
143+
android:fadingEdge="horizontal"
144+
android:marqueeRepeatLimit="marquee_forever"
145+
android:scrollHorizontally="true"
146+
android:singleLine="true"
147+
android:textColor="@android:color/white"
148+
android:textSize="15sp"
149+
android:textStyle="bold"
150+
tools:ignore="RtlHardcoded"
151+
tools:text="The Video Title LONG very LONG" />
152+
153+
<org.schabi.newpipe.views.NewPipeTextView
154+
android:id="@+id/channelTextView"
155+
android:layout_width="match_parent"
156+
android:layout_height="wrap_content"
157+
android:ellipsize="marquee"
158+
android:fadingEdge="horizontal"
159+
android:marqueeRepeatLimit="marquee_forever"
160+
android:scrollHorizontally="true"
161+
android:singleLine="true"
162+
android:textColor="@android:color/white"
163+
android:textSize="12sp"
164+
tools:text="The Video Artist LONG very LONG very Long" />
165+
166+
</LinearLayout>
167+
168+
<FrameLayout
169+
android:layout_width="wrap_content"
170+
android:layout_height="match_parent"
171+
android:layout_weight="1">
172+
173+
<org.schabi.newpipe.views.NewPipeTextView
174+
android:id="@+id/audioTrackTextView"
175+
android:layout_width="wrap_content"
176+
android:layout_height="35dp"
177+
android:layout_gravity="right"
178+
android:layout_marginEnd="8dp"
179+
android:background="?attr/selectableItemBackground"
180+
android:ellipsize="end"
181+
android:gravity="center"
182+
android:minWidth="0dp"
183+
android:padding="@dimen/player_main_buttons_padding"
184+
android:singleLine="true"
185+
android:textColor="@android:color/white"
186+
android:textStyle="bold"
187+
android:visibility="gone"
188+
tools:ignore="HardcodedText,RtlHardcoded"
189+
tools:text="English (United States) original"
190+
tools:visibility="visible" />
191+
</FrameLayout>
146192

147-
<org.schabi.newpipe.views.NewPipeTextView
148-
android:id="@+id/channelTextView"
149-
android:layout_width="match_parent"
150-
android:layout_height="wrap_content"
151-
android:ellipsize="marquee"
152-
android:fadingEdge="horizontal"
153-
android:marqueeRepeatLimit="marquee_forever"
154-
android:scrollHorizontally="true"
155-
android:singleLine="true"
156-
android:textColor="@android:color/white"
157-
android:textSize="12sp"
158-
tools:text="The Video Artist LONG very LONG very Long" />
159193
</LinearLayout>
160194

161-
<org.schabi.newpipe.views.NewPipeTextView
162-
android:id="@+id/audioTrackTextView"
163-
android:layout_width="0dp"
164-
android:layout_height="35dp"
165-
android:layout_marginEnd="8dp"
166-
android:layout_weight="1"
167-
android:background="?attr/selectableItemBackground"
168-
android:ellipsize="end"
169-
android:gravity="center"
170-
android:minWidth="0dp"
171-
android:padding="@dimen/player_main_buttons_padding"
172-
android:singleLine="true"
173-
android:textColor="@android:color/white"
174-
android:textStyle="bold"
175-
android:visibility="gone"
176-
tools:ignore="HardcodedText,RtlHardcoded"
177-
tools:text="English (United States) original"
178-
tools:visibility="visible" />
179-
180195
<org.schabi.newpipe.views.NewPipeTextView
181196
android:id="@+id/qualityTextView"
182197
android:layout_width="wrap_content"

0 commit comments

Comments
 (0)