2017-04-27 9 views
0

가로 목록보기에서 항목 (0-23)을 가로로 스크롤하려고합니다.가로 목록보기의 높이 줄이기 - 자마린 양식

목록보기가 가로 방향으로 표시되지만 목록보기의 높이가 내용에 줄 바꿈되지 않습니다. RelativeLayout을 xConstraint, yConstraint, width 및 heightConstraint와 함께 사용해 보았습니다. 매개 변수 값을 변경하려고 시도했지만 listview는 값을 변경하는 모든 시간이 사라졌습니다.

ListView lv = new ListView 
     { 
      SeparatorVisibility = SeparatorVisibility.None, 
      ItemsSource = items, 
      Rotation = 270, 

      ItemTemplate = new DataTemplate(() => 
      { 

       Label label = new Label() 
       { 
        Rotation = 90, 
        TextColor = Color.Black, 
        HorizontalTextAlignment = TextAlignment.Center, 
        FontSize = Device.GetNamedSize(NamedSize.Small, new Label()) 
       }; 
       label.SetBinding<User>(Label.TextProperty, indexer => indexer.Time); 

       return new ViewCell 
       { 
        View = new StackLayout 
        { 
         Children = 
          { 
          label 
         } 
        } 
       }; 
      }) 
     }; 

     RelativeLayout rLayout = new RelativeLayout(); 

     rLayout.Children.Add(lv, 
          xConstraint: Constraint.RelativeToParent((parent) => 
           { 
            return (parent.Width/0.5) - 30; 
           }), 
          yConstraint: Constraint.RelativeToParent((parent) => 
           { 
            return (parent.Height/-0.5) + 3; 
           }), 
          widthConstraint: Constraint.Constant(60), 
          heightConstraint: Constraint.RelativeToParent((Parent) => 
           { 
            return (Parent.Height/10); 
           }) 
     ); 

     Content = new StackLayout 
     { 
      Children = { 
       rLayout 
      } 
     }; 

저는 xamarin을 처음 사용하고 있습니다. 제가 잘못 가고있는 방식 일 수 있습니다. 그렇다면 나에게 맞는 것을 제안 해주세요.하지만 전체적으로 나는 항목으로만 숫자를 갖는 가로 목록보기를 원합니다. 그리고 높이를 내용으로 감싸고 싶습니다.

어떤 도움이 사전에 .. 감사 감지 할 수있을 것이다 ..

+0

같은 간단한 시나리오 아마 사용하는 것이''' 내부'. 'ItemsSource' 속성을 가진'StackLayout'에 기반한 커스텀 컨트롤을 만듭니다. –

+0

아마도 [회전식보기] (https://blog.xamarin.com/flipthrough-items-with-xamarin-forms-carouselview/)를 사용해 볼 수 있습니다. 비록 당신의 유스 케이스에 맞을 지 확실하지 않다. –

+0

당신 대답에 감사합니다 @ EgorGromadskiy 그것은 나를 도울 .. 늦게 답장을 보내 주셔서 죄송합니다 .. – user5598997

답변

0

리스트 뷰 내부 항목의 자동 높이를 확인하려면 다음 당신은 당신의 XAML 파일에 HasUnevenRow="true"을 사용해야합니다.

예 :

<ListView x:Name="SomeList" HasUnevenRows="True" ItemsSource="{Binding ...}" SeparatorVisibility="None"> 
     <ListView.ItemTemplate> 
      <DataTemplate> 
      <ViewCell> 
       <ViewCell.View> 
       <Label HorizontalOptions="CenterAndExpand" TextColor="Blue" Margin="0,5,0,5" Text="{Binding ....}" FontSize="Small" HeightRequest="35"/> 
       </ViewCell.View> 
      </ViewCell> 
      </DataTemplate> 
     </ListView.ItemTemplate> 
     </ListView> 
+0

답장을 보내 주셔서 감사합니다 Prabhat .. 나는 그것을 시도했지만 결과는 내 질문에 설명과 동일합니다 .. Logged – user5598997