2017-11-27 5 views
1

私はアンドロイドに新しいので、私は科学計算機を構築しようとしていました。だから私はedit text計算の結果を表示している。コンポーネントが重なり合っています

私がやっていたことは、その上にボタンを用意して、人々が電卓の前進機能にアクセスできるようにすることでした。

私は様々な質問を読んでそれを試みましたが、うまくいかないようです。

明らかに重複しています。

しかしedittextは、imagebuttonの上に表示され、クリックイベントはimagebuttonで役に立たなくなります。私はedittextの上に私のimagebuttonを置く方法

コード

<ImageButton 
     android:contentDescription="View advance features" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:id="@+id/go_advance" 
     android:scaleType="fitXY" 
     android:layout_alignParentTop="@id/linearLayout" 
     android:layout_alignParentBottom="@id/linearLayout" 
     android:background="@drawable/round_buttons" 

     /> 
    <LinearLayout 
     android:id="@+id/linearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     app:layout_constraintBottom_toTopOf="parent" 
     app:layout_constraintEnd_toStartOf="parent" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toTopOf="parent"> 



     <EditText 
      android:id="@+id/editText3" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="fill_horizontal" 
      android:height="225dp" 
      android:textSize="24sp" 
      android:gravity="end|bottom" 
      android:ems="10" 
      android:maxLines="2" 
      android:inputType="textMultiLine" 
      tools:layout_editor_absoluteX="104dp" 
      tools:layout_editor_absoluteY="207dp" /> 

enter image description here

+1

LinearLayoutの必要はありません。 RelativeLayoutの代わりに、このUIのための完璧なコンテナと思われるGridLayoutを使用します。 –

+0

'相対>線形(テキスト+グリッドレイアウトの編集)、画像ボタン'これは実際の構造です –

+1

私はそれを得る、何を言っているのですか、ありがとう@BernoulliGate –

答えて

1

親レイアウトとしてRelativeLayoutを使用していると思います。 LinearLayoutの後にImageButtonを配置します。

<RelativeLayout> 
    <LinearLayout> 
     ... 
     edit text, buttons etc 
     ... 
    </LinearLayout> 
    <ImageButton/> 
</RelativeLayout> 
関連する問題