❓ Help Xamarin form

If Else

Established
Mga sir paano e center Yung text na Hindi magalaw Yung background image .. tried horizontal alignment: center pero ayaw parin
1709034961316.webp
 
Para ma-center ang text nang hindi naaapektuhan ang background image, maaari mong subukan ang mga sumusunod:

1. Gumamit ng RelativeLayout:
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/background_image"
        android:scaleType="centerCrop" /> <!-- pwedeng adjust depende sa needs mo -->

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Naka-center na text"
        android:textColor="#FFFFFF" />
</RelativeLayout>

2. Gumamit ng ConstraintLayout:
XML:
<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">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/background_image"
        android:scaleType="centerCrop"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Naka-center na text"
        android:textColor="#FFFFFF"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

Subukan mo itong mga halimbawa at i-adjust ang parameters base sa iyong layout requirements. Sana makatulong ito sa pag-cecenter ng text sa iyong background image.
 
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="You do not have permission to view the full content of this post. Log in or register now."
xmlns:x="You do not have permission to view the full content of this post. Log in or register now."
x:Class="Myfirstapp.Jerson">
<ContentPage.Content>
<StackLayout>


<Image Source="mcc.jpg" Aspect="AspectFill"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>

<Label Text="Mcc Parking System" TextColor="red"
VerticalOptions="FillAndExpand"
HorizontalOptions="EndAndExpand" />


</StackLayout>
</ContentPage.Content>
</ContentPage>


Ito Yung code paki center Ng label
 
Code:
 <Label Text="Mcc Parking System" TextColor="red"
            VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" />

Patry po nito
 

About this Thread

  • 4
    Replies
  • 560
    Views
  • 2
    Participants
Last reply from:
If Else

Trending Topics

Online now

Members online
586
Guests online
1,228
Total visitors
1,814

Forum statistics

Threads
2,268,865
Posts
28,924,840
Members
1,243,117
Latest member
anonymousssskamo
Back
Top