で、ボタンの境界線の色を変更する私が使用してみました:のonClick
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1sp"
android:background="#000000"></FrameLayout>
が、制約がちょうどグラグラ行ったとして、それだけで、失敗に終わりました。私は全面的に調査しましたが、効果的な解決策を見つけることができませんでした。私は髪の毛を裂く寸前です。
button_msg = (Button)findViewById(R.id.button_red);
button_msg.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
greeting = "赤色です" ;
btn_send_msg.callOnClick();
}});
button_msg = (Button)findViewById(R.id.button_blue);
button_msg.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
greeting = "青色です" ;
btn_send_msg.callOnClick();
}});
をだから私は赤押すと、境界線(黒、など)だけでそのボタンの周りに表示され、他のボタンのためにその逆:私のコードは次のようになります。プログラムが現在どの状態にあるかを視覚的に表現するだけです。
編集:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@color/pale_blue"
android:layout_height="match_parent"
android:id="@+id/linearlayout">
<ImageView
android:layout_width="382dp"
android:layout_height="62dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/alumis_logo"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:layout_editor_absoluteY="-4dp"
app:layout_constraintHorizontal_bias="0.454" />
<Button
android:id="@+id/button_blue"
android:layout_width="78dp"
android:layout_height="38dp"
android:layout_marginBottom="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="1dp"
android:background="#0000ff"
android:text="青色"
app:layout_constraintBottom_toTopOf="@+id/button_green"
app:layout_constraintHorizontal_bias="0.973"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_red"
app:layout_constraintVertical_bias="0.284"
app:layout_constraintVertical_chainStyle="packed"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1" />
<Button
android:id="@+id/button_green"
android:layout_width="78dp"
android:layout_height="38dp"
android:layout_marginBottom="1dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="1dp"
android:background="#00ff00"
android:text="緑色"
app:layout_constraintBottom_toTopOf="@+id/button_yellow"
app:layout_constraintHorizontal_bias="0.973"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_blue"
app:layout_constraintVertical_bias="0.407"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1" />
<Button
android:id="@+id/button_yellow"
android:layout_width="78dp"
android:layout_height="38dp"
android:layout_marginBottom="40dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="1dp"
android:text="黄色"
android:background="#ffff00"
app:layout_constraintHorizontal_bias="0.973"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_green"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.04"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
/>
<Button
android:layout_width="129dp"
android:layout_height="48dp"
android:text="Send"
android:id="@+id/btn_send"
tools:layout_constraintTop_creator="1"
tools:layout_constraintLeft_creator="1"
app:layout_constraintTop_toTopOf="@+id/msg_input"
app:layout_constraintLeft_toRightOf="@+id/msg_input"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.466"
android:layout_marginTop="-14dp" />
<EditText
android:layout_width="275dp"
android:layout_height="50dp"
android:id="@+id/msg_input"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="1dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="460dp" />
<ScrollView
android:id="@+id/scrollView"
android:layout_width="269dp"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="68dp"
app:layout_constraintBottom_toTopOf="@+id/msg_input"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1">
<TextView
android:id="@+id/textView"
android:layout_width="394dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:scrollbars="vertical"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="49dp" />
</ScrollView>
<Button
android:id="@+id/button_red"
android:layout_width="78dp"
android:layout_height="38dp"
android:layout_marginBottom="1dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="60dp"
android:background="#ff0000"
android:text="赤色"
app:layout_constraintBottom_toTopOf="@+id/button_blue"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1" />
</android.support.constraint.ConstraintLayout>
あなたがあるため、パディングの境界を取得しているように思える –
ボタンのウルXMLコードを提供することができます。ボタンの上に何かがあり、テキストの幅が100%に設定され、背景色(透明ではない)がありますか? – Icewine
完全なコードを投稿できますか?私はボタンの色を変更する上記のコードはありません。 – Anoop