Xamarin List View Item Text in horizontal and vertical middle not working
up vote
0
down vote
favorite
So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.
I tried this:
<ListView x:Name="EssenListView"
ItemsSource="{Binding EssenAnTag}"
Footer=""
SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
HasUnevenRows="true"
RefreshCommand="{Binding EssenLadenCommand}"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding Laedt, Mode=OneWay}"
ItemSelected="EssenGewaehlt">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
</StackLayout>
<Label HeightRequest="15" BackgroundColor="White"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.
listview xamarin.forms centering
add a comment |
up vote
0
down vote
favorite
So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.
I tried this:
<ListView x:Name="EssenListView"
ItemsSource="{Binding EssenAnTag}"
Footer=""
SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
HasUnevenRows="true"
RefreshCommand="{Binding EssenLadenCommand}"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding Laedt, Mode=OneWay}"
ItemSelected="EssenGewaehlt">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
</StackLayout>
<Label HeightRequest="15" BackgroundColor="White"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.
listview xamarin.forms centering
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.
I tried this:
<ListView x:Name="EssenListView"
ItemsSource="{Binding EssenAnTag}"
Footer=""
SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
HasUnevenRows="true"
RefreshCommand="{Binding EssenLadenCommand}"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding Laedt, Mode=OneWay}"
ItemSelected="EssenGewaehlt">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
</StackLayout>
<Label HeightRequest="15" BackgroundColor="White"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.
listview xamarin.forms centering
So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.
I tried this:
<ListView x:Name="EssenListView"
ItemsSource="{Binding EssenAnTag}"
Footer=""
SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
HasUnevenRows="true"
RefreshCommand="{Binding EssenLadenCommand}"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding Laedt, Mode=OneWay}"
ItemSelected="EssenGewaehlt">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
</StackLayout>
<Label HeightRequest="15" BackgroundColor="White"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.
listview xamarin.forms centering
listview xamarin.forms centering
asked 2 days ago
Kai
396
396
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
Adding HorizontalTextAlignment="Center" property in your Label control, like this:
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
add a comment |
up vote
0
down vote
Use HorizontalTextAlignment="Center" to align text in Label.
HorizontalOptions="Center" align the Label itself.
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Adding HorizontalTextAlignment="Center" property in your Label control, like this:
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
add a comment |
up vote
0
down vote
Adding HorizontalTextAlignment="Center" property in your Label control, like this:
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
add a comment |
up vote
0
down vote
up vote
0
down vote
Adding HorizontalTextAlignment="Center" property in your Label control, like this:
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
Adding HorizontalTextAlignment="Center" property in your Label control, like this:
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
answered yesterday
Cherry Bu
82328
82328
add a comment |
add a comment |
up vote
0
down vote
Use HorizontalTextAlignment="Center" to align text in Label.
HorizontalOptions="Center" align the Label itself.
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
Use HorizontalTextAlignment="Center" to align text in Label.
HorizontalOptions="Center" align the Label itself.
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
up vote
0
down vote
Use HorizontalTextAlignment="Center" to align text in Label.
HorizontalOptions="Center" align the Label itself.
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Use HorizontalTextAlignment="Center" to align text in Label.
HorizontalOptions="Center" align the Label itself.
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited yesterday
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered yesterday
Ataberk Uzkal
13
13
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204245%2fxamarin-list-view-item-text-in-horizontal-and-vertical-middle-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password