最用户友好的选项为Android应用程序布局应用程序、布局、友好、选项

2023-09-05 10:02:00 作者:官方爸爸

让我面临的问题是不是主观判断什么是最好的用户(我认为),但可用的选项来说明定位。

SO the problem I am facing is not about subjectively judge what is best for the user (I think) but what options are available to illustrate positioning.

想到某种团队运动应用程序,在那里你可以把小点的球员(然后我可以取代与重presents玩家一些UI组件的点)像这样的在这里你可以拖放红色和蓝色小点间距

Think of some sort of team sports app, where you can put little dots for players (and then I can replace the dots with some UI component that represents the player) something like this where you can drag and drop the red and blue dots

我想这有一个gridview,它是pretty的辛苦,因为我需要的行/ COLS一组号码,当你在大分辨率的手机,他们也没有形成规模,所以开始盗号上自定义组件寿感觉就像我重新发明轮子。

I tried this with a gridview, and it's pretty hard because I need to have a set number of rows/cols and they don't scale when you are in a phone with bigger resolution, so started hacking on a "custom component" tho it feels like I am reinventing the wheel.

有没有比我书面方式自己的组件是更好的选择?

Is there a better option than writting my own component?

如果这有什么差别,我米使用xamarin.android

If it makes any difference, I m using xamarin.android

推荐答案

我会实现这个使用MvvmCross数据绑定对集合绑定的FrameLayout。

I'd implement this using MvvmCross Data-binding against a collection-bound FrameLayout.

该方法的这种核心使用了 TranslationX TranslationY 关于儿童性查看 s的父的FrameLayout

This core of the method uses the TranslationX and TranslationY properties on child Views within the parent held within a parent FrameLayout.

父是:

<?xml version="1.0" encoding="utf-8"?>
<pointsongrid.BindableFrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:local="http://schemas.android.com/apk/res/points.on.grid"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  local:MvxBind="ItemsSource Points"
  local:MvxItemTemplate="@layout/item"/>

列表项是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res/points.on.grid"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    local:MvxBind="TranslationX X, Converter=X;TranslationY Y, Converter=Y"
  >
  <LinearLayout
    android:layout_width="20dp"
    android:layout_height="20dp"
    local:MvxBind="BackgroundColor Color, Converter=NativeColor"
  />      
  <TextView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    local:MvxBind="Text Player"
    />      
</LinearLayout>

整个code是有点长了计算器,所以我贴一个快速回购展示 - HTTPS ://github.com/slodge/MvvmCross-Players - 数据绑定的FrameLayout有可能确实对改善 - 看看在LinearLayout中code的主要MvvmCross回购的一些想法,如果你需要的支持改变列表(如的ObservableCollection)。

The entire code is a bit long for StackOverflow so I posted a quick repo to demonstrate - https://github.com/slodge/MvvmCross-Players - the databound FrameLayout there could certainly be improved on - take a look at the LinearLayout code in the main MvvmCross repo for some ideas if you need support for changing lists (e.g. ObservableCollection).

结果看起来有点像: