Tob*_*obi 6 c# xaml android xamarin xamarin.forms
我正在尝试编写一个Xamarin.Forms聊天应用程序.问题是:在Android上,一旦键盘显示整个页面(包括ActionBar)向上移动.我可以通过使用调整页面大小的NuGet包来修复IOS上的问题.
我已经尝试WindowSoftInputMode = Android.Views.SoftInput.AdjustResize在Android项目的MainActivity.cs中设置但它不起作用.我还尝试通过重新计算屏幕大小来手动调整页面大小,但我还没有找到解决方案来获取键盘大小以便在不同设备上进行精确计算.
以前有人遇到过同样的问题吗?是否有适用于所有受支持平台的官方Xamarin.Forms解决方案?
这是我到目前为止的聊天布局:
<ContentPage.Content>
<StackLayout Padding="0">
<ScrollView>
<ListView HasUnevenRows="true" x:Name="lvChat" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical" VerticalOptions="Fill" HorizontalOptions="Fill" Padding="5">
<Label Text="{Binding Author, StringFormat='{0}: '}" TextColor="Navy" FontSize="14" />
<Label Text="{Binding Text}" TextColor="Black" FontSize="15" />
<Label Text="{Binding Time}" TextColor="Black" FontSize="14" />
<!-- Format for time.. , StringFormat='{0:HH:mm}' -->
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollView>
<StackLayout Orientation="Horizontal" Padding="0" Margin="5, 5, 5, 5">
<Entry Keyboard="Chat" x:Name="tbxChatInput" HorizontalOptions="FillAndExpand" Placeholder="Send a Message..." />
<Button x:Name="btnSendMsg" HorizontalOptions="End" Text="Send" Margin="5"/>
</StackLayout>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
提前致谢!
尝试windowSoftInputMode在 Android Manifest 中进行设置,例如:
<application ... >
<activity
android:windowSoftInputMode="adjustResize" ... >
...
</activity>
...
</application>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
844 次 |
| 最近记录: |