2017-11-16 8 views
0

XMLを使用して制約レイアウトをデザインしています。OpenSansBTextViewのAndroid中心のテキスト

私にはOpenSansBTextViewがあり、テキストを中央に配置する必要があります。 は水平方向にに、は垂直方向にではありません。どうしてか分かりません。ここに私のXMLファイルがあります。私の間違いを見ることができますか?あなたがで動作するように多くのコードを提供していない

<android.support.constraint.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" 
    android:background="@color/colorAccent" 
    android:id="@+id/dashboard"> 

    <com.doyousonder.android.utils.RochesterTextView 
     android:id="@+id/YourActivity" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     android:layout_marginStart="25dp" 
     app:layout_constraintVertical_bias="0.34" 
     android:text="@string/YourActivity" 
     android:textColor="@color/colorPrimaryMoreDark" 
     android:textSize="23sp" /> 

    <com.doyousonder.android.utils.OpenSansRTextView 
     android:id="@+id/YouVoted" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/YourActivity" 
     android:layout_marginTop="15dp" 
     android:layout_marginStart="20dp" 
     android:text="@string/YouVoted" 
     android:textColor="@color/colorPrimaryMoreDark" 
     android:textSize="15sp" /> 

    <com.doyousonder.android.utils.OpenSansSBTextView 
     android:id="@+id/VoteCount" 
     android:layout_width="29dp" 
     android:layout_height="35dp" 
     app:layout_constraintStart_toEndOf="@+id/YouVoted" 
     app:layout_constraintTop_toTopOf="@+id/YouVoted" 
     app:layout_constraintBottom_toBottomOf="@+id/YouVoted" 
     android:layout_marginStart="5dp" 
     android:background="@drawable/more_curved_edge_button_button_primarycolor_background" 
     android:gravity="center" 
     android:text="1" 
     android:textAlignment="center" 
     android:textSize="25sp" /> 
+0

opensansbtextviewとは何ですか? –

+0

@AbdulWaheed通常のテキストビューは、いくつかの追加機能でのみ再設計されました –

+0

あなたが使用しているカスタムテキストビュー用のコードを投稿してください –

答えて

0

、すなわち何youVoted変数です。私はyouvotedがあなたの親のレイアウトだと仮定しています

私は問題があると思います。 youvotedの開始でスタート私はあなたが作られて間違いはあなたのTextViewがあなたのyouvotedレイアウトの終わりに開始すべき旨の代わりに、それを言っていると信じて、これらの代わりに

...other layout info 
    app:layout_constraintBottom_toBottomOf="@+id/YouVoted" 
    app:layout_constraintStart_toStartOf="@+id/YouVoted" 
    app:layout_constraintTop_toTopOf="@+id/YouVoted" 
    app:layout_constraintEnd_toEndOf="@+id/YouVoted"/> 

説明 をすべき試してみてくださいレイアウト。

変更app:layout_constraintStart_toEndOf="@+id/YouVoted"

app:layout_constraintStart_toStartOf="@+id/YouVoted"には、エンド制約を追加します。

app:layout_constraintEnd_toEndOf="@+id/YouVoted" 
関連する問題