質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

2回答

1666閲覧

XMLのプレビューにアクションバーが表示されない。

kurus

総合スコア14

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2019/03/15 12:04

編集2019/03/15 15:23

前提・実現したいこと

Android StudioでAndroidアプリを作るために勉強中です。
今回は電卓アプリを作ろうと思い、ButtonViewとTextViewのみを設置して実装はしていない状態です。

発生している問題・エラーメッセージ

acutiviy_main.xmlのプレビューにアクションバーが表示されません。
実際にエミュレーターで起動するとアクションバーは表示されます。
xmlでアクションバーが表示さないことから、Viewがずれてしまい、画像のようにViewがはみだしてしまいます。
イメージ説明
イメージ説明

該当のソースコード

styles.xml

<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> </resources>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kurus.calculator"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

MainActivity.java

package com.kurus.calculator; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }

試したこと

AppThemeを変更したり、Rebuild、Invalidate And Restartは試したのですが、ほかに立ち上げたプロジェクトもすべてアクションバーが表示されません。
ちなみにエミュレーターはNexus 5X API28です
Androidのバージョンは3.3.1です。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

【アクションバー】
図のShow Layout Decorationsにチェックを入れることでアクションバーは表示されました。
イメージ説明

【レイアウトのずれ】
また、レイアウトがずれる件は、ConstraintLayoutネストされているLinearLayout(vertical)の
layout_heightやlayout_widthをmatch_constraintに変更することで解消されました。

投稿2019/03/15 15:55

kurus

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

activity_main.xml

<?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:layout_height="match_parent" tools:context=".MainActivity"> <LinearLayout android:layout_width="395dp" android:layout_height="715dp" android:layout_marginStart="8dp" android:layout_marginLeft="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:layout_marginBottom="8dp" android:orientation="vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <TextView android:id="@+id/txtStatus" android:layout_width="match_parent" android:layout_height="20dp" android:gravity="right|center_vertical" android:textSize="18sp" /> <TextView android:id="@+id/txtAnswer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="right|center_vertical" android:padding="16dp" android:text="0" android:textSize="70sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btnSeven" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="7" android:textSize="46sp" /> <Button android:id="@+id/btnEight" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="8" android:textSize="46sp" /> <Button android:id="@+id/btnNine" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="9" android:textSize="46sp" /> <Button android:id="@+id/btnDivision" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="÷" android:textSize="46sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btnFour" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="4" android:textSize="46sp" /> <Button android:id="@+id/btnFive" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="5" android:textSize="46sp" /> <Button android:id="@+id/btnSix" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="6" android:textSize="46sp" /> <Button android:id="@+id/btnMultiplation" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="×" android:textSize="46sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btnOne" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="1" android:textSize="46sp" /> <Button android:id="@+id/btnTwo" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="2" android:textSize="46sp" /> <Button android:id="@+id/btnThree" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="3" android:textSize="46sp" /> <Button android:id="@+id/btnMinus" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="-" android:textSize="46sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <Button android:id="@+id/btnClear" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="C" android:textSize="46sp" /> <Button android:id="@+id/btnZero" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="0" android:textSize="46sp" /> <Button android:id="@+id/btnEqual" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="=" android:textSize="46sp" /> <Button android:id="@+id/btnPlus" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:onClick="buttonIsClicked" android:text="+" android:textSize="46sp" /> </LinearLayout> </LinearLayout> </android.support.constraint.ConstraintLayout>

投稿2019/03/15 15:23

kurus

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問