Пользовательский шрифт для моего приложения Android не отображается на физическом устройствеAndroid

Форум для тех, кто программирует под Android
Ответить
Гость
 Пользовательский шрифт для моего приложения Android не отображается на физическом устройстве

Сообщение Гость »


I've tried a bunch of things, like setting the font on a layout level, creating a typeface and setting it, and cleaning and rebuilding the project. The font will show up in the editor, and last I was able to try it, the emulator (though my computer hasn't been the greatest lately), but not my Samsung Galaxy Note 3. Here's the Java code:

`

package com.example.benkyoblobandroid; import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.Group; import android.content.Intent; import android.graphics.Typeface; import android.os.Bundle; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; public class BlobView extends AppCompatActivity { ImageButton pet; Group infoGroup; ImageButton studyTimeButton; TextView HPLabel; TextView EXPLabel; TextView EXP; TextView lvl; Typeface pixelFont; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); HPLabel = (TextView) findViewById(R.id.HP); EXPLabel = (TextView) findViewById(R.id.EXPLabel); EXP = (TextView) findViewById(R.id.EXP); lvl = (TextView) findViewById(R.id.lvl); pixelFont = Typeface.createFromAsset(getAssets(), "font/fff_forward_regular"); HPLabel.setTypeface(pixelFont); EXPLabel.setTypeface(pixelFont); EXP.setTypeface(pixelFont); lvl.setTypeface(pixelFont); pet = (ImageButton) findViewById(R.id.pet); infoGroup = (Group) findViewById(R.id.infoGroup); pet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { infoGroup.setVisibility(infoGroup.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); } }); studyTimeButton = (ImageButton) findViewById(R.id.studyTimeButton); studyTimeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switchActivity(StudyTimeView.class); } }); } void switchActivity(Class activity) { Intent activityIntent = new Intent(this, activity); startActivity(activityIntent); } }` And the XML code:

Attached are how it looks in the editor vs. how it looks on my Android, and also the file hierarchy. Font works in editor.Font does not work on device.Fonts in the file hierarchy.


Источник: https://stackoverflow.com/questions/780 ... cal-device
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»