背景色を全て赤にしたいです。
コード public class MainActivity extends Activity{ private FrameLayout frameLayout; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); frameLayout = new FrameLayout(this); frameLayout.setBackgroundColor(Color.RED); } }
コード <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/FrameLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.fireworks.MainActivity" > </FrameLayout>
これでできると思ったのですが無理でした。
どこを直せばいいのでしょうか?
また、背景に色をつけるのを調べたときにframeLayout.setBackgroundColor(Color.RED);と記述してあったのですが、
frameLayout.というのはなぜ書く必要があるのでしょうか?
よろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/03/30 07:27
2016/03/30 07:44 編集
2016/03/30 08:35